Problem F
Work Reduction
Paperwork is beginning to pile up on your desk, and tensions
at the workplace are starting to mount. Your boss has
threatened to fire you if you don’t make any progress by the
end of the day. You currently have
The only hope for you now is to hire help. There are various agencies which offer paperwork reduction plans:
For
Note that work can never be reduced to less than
Your task now is to produce a sorted table of agency names and their respective minimum costs to solve your workload problem.
Input
The first line of input consists of a single positive
integer representing the number of cases to follow, at most
Output
For each test case, print “Case
Sample Input 1 | Sample Output 1 |
---|---|
2 100 5 3 A:1,10 B:2,5 C:3,1 1123 1122 5 B:50,300 A:1,1000 C:10,10 D:1,50 E:0,0 |
Case 1 C 7 B 22 A 37 Case 2 E 0 A 1 D 1 C 10 B 50 |