Contest Problem Assignment
Time limit1sMemory limit128 MB
Split up to ten contest problems among three members with individual time limits to solve the largest possible count.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Bit manipulation
- Solved
- No attempts yet
Problem
A team of three is competing in a programming contest. All three have read every problem and estimated, for each one, how many minutes it would take that person to solve it. The team now wants to split the problems so that it solves as many of them as possible in the time that is left.
Every member writes the whole solution out on paper before sitting down at the computer, so nobody ever waits for the machine. Only one condition applies: for each team member, the estimated solving times of the problems that member takes must add up to no more than the time left in the contest.
A problem goes to at most one member, and a member cannot be given a problem that person is unable to solve.
Input
The first line has the number of test cases (). Each test case is given as follows.
- One line with the number of problems () and the number of minutes left in the contest ().
- Three lines with integers each. Line holds the solving times of the th team member, and the th integer on that line, , is the time in minutes that member needs for problem (). It is if that member cannot solve the problem.
Output
For each test case, print on one line the largest number of problems the team can solve.