AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
3. Our Experts are looking for yours ?.

# corejava-programming: Java Program-Staying In a Hotel

 There is a school trip being organized for kids. The hotel the group is staying in can offer them one big room with enough beds to suit any group of visitors, and several smaller rooms with B beds all together. The children have heard many strange and frightening stories about the big room. That´s why not even one of them wants to sleep in the big room. Furthermore not every kid would like to sleep in any bed. Your goal is to assign B beds from the smaller rooms in such a way that the maximal number of children are happy (a child is happy when it gets to sleep in one of the beds it has selected). Input Specification : The first line contains a positive integer t<=1000 indicating the number of test cases. Each test case is an instance of the problem defined above. The first line of each test case is a pair of positive integers L and B (the number of children L<=100 and beds B<=100). The next lines contain a sequence of (c,b) pairs ending with two zeros. (c,b) means that the child c will be happy if it gets to sleep in bed b. Each test case ends when it encounters 0 0. Output Specification : For each test case print the maximal number of happy children. Sample Input: 3 3 3 1 1 2 1 2 2 3 2 3 3 0 0 4 3 1 1 1 3 2 1 3 1 3 2 4 2 0 0 4 2 1 1 1 2 2 1 2 2 3 1 3 2 4 1 4 2 0 0 Sample Output: 3 3 2 Input Explanation: First 3 is number of test case 1st test case is : 3 3-3 children and 3 beds 1 1-child 1 wants bed 1 2 1-child 2 wants bed 1 2 2-child 2 wants bed 2 3 2-child 3 wants bed 2 3 3-child 3 wants bed 3 0 0-both zero means end of this test case 2nd test case is : 4 3-4 children and 3 beds 1 1-child 3 wants bed 3 1 3-child 3 wants bed 3 2 1-child 3 wants bed 3 3 1-child 3 wants bed 3 3 2-child 3 wants bed 3 4 2-child 3 wants bed 3 0 0-both zero means end of this test case 3rd test case is: 4 2-4 children and 2 beds 1 1-child 1 wants bed 1 1 2-child 1 wants bed 2 2 1-child 2 wants bed 1 2 2-child 2 wants bed 2 3 1-child 3 wants bed 1 3 2-child 3 wants bed 2 4 1-child 4 wants bed 1 4 2-child 4 wants bed 2 0 0-both zero means end of this test case Output Explanation: 3-maximal 3 children are happy in 1st test case 3-maximal 3 children are happy in 2nd test case 2-maximal 2 are happy in 3rd test case. corejava x 353programming x 168 Posted On : 2016-12-17 14:36:48.0 Aarti Kumar 5900 5