The Cursed RoomProblem code: MMATCH |
All submissions for this problem are available.
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 alltogether.
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
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.
Output
For each test case print the maximal number of happy children.
Example
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 Output: 3 3 2
| Date: | 2008-12-01 |
| Time limit: | 5s |
| Source limit: | 50000B |
| Languages: | All except: PERL6 |
Comments
Loading Comments...
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
Loading Submissions...RECENT ACTIVITY FOR THIS PROBLEM:
Loading Recent Activity...HELP
Program should read from standard input and write to standard output.
After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.
