The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
STATEMENT
To promote competitive coding on campus, the computer science department has decided to add a new course titled "Introduction to Algorithms" to the first year curriculum of all undergraduate programs. However, it might not be feasible to have all the students attend the course in a single semester due to limitations pertaining to faculty and/or infrastructure.
To overcome that, the course will be conducted twice. (Once in both semesters.) Some students will take it in the first semester while the remaining will do it in the second semester. However, to make the managing of the course easier, the department wants to make sure that students belonging to the same program take the course in the same semester. Your job is to find out if such a division of students is possible.
INPUT
The first line will contain an integer T, denoting the number of test cases.
Each test case contains two lines.
The first line of each test case will contain two space separated integers, N and C, the number of programs currently offered and the maximum number of students that can take the course in one semester.
The second line contains N space separated integers, representing the number of students in each of the N programs.
1
1
0
0
OUTPUT
For each test case, in the first line print "YES" or "NO" depending on whether or not such a division is possible.
If "YES", in the first line print the number of students (in sorted order) of the programs that will take the course in the first semester, and in the second line print the number of students (in sorted order) of the programs that will take the course in second semester.
If more that one division is possible print the one where the values in the first line are lexicographically smallest. See the example test case for more clarification.
EXAMPLE
4
5 7
1 2 3 4 5
5 8
1 2 3 4 5
5 15
1 2 3 4 5
5 10
0 0 0 0 0
NO
YES
1 2 4
3 5
YES
1 2 3 4 5
YES
0 0 0 0 0
Case 1: Impossible
Case 2: Possible divisions: {(1, 2, 4), (3, 5)}, {(3, 5), (1, 2, 4)}, {(1, 2, 5), (3, 4)} and {(3, 4), (1, 2, 5)}. The first one contains the least lexicographic ordering of the first set, therefore that is the answer.
The next 2 cases have empty first line because it is possible to fit the entirety of the student body in the second semester alone.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll