Pick and order contest problems to solve the most within the time limit with the smallest total penalty time.
Easy3GreedySortingInterviewNo attempts yetTime limit1sMemory limit256 MBYou are a contestant in a programming contest. Your goal is to solve as many problems as you can inside the contest duration, and to keep the total time as small as possible.
Suppose you can estimate in advance, in minutes, how long each problem will take you. Plan the order in which you solve the problems so that the number of solved problems is as large as possible and, under that condition, the total time is as small as possible. The time of one problem is the number of minutes from the start of the contest to the moment you submit it, and the total time is the sum of that value over every problem you solve. While planning you may assume that every problem is accepted on the first submission at exactly the estimated time, so you do not have to account for penalty time. You can work on only one problem at a time, and you cannot work on two problems in parallel.
The first line contains the number of test cases T (1≤T≤20).
Each test case takes two lines. The first line contains the number of contest problems N (1≤N≤20) and the contest duration L (1≤L≤1500), separated by a space. The second line contains the N estimated solving times, separated by spaces, each an integer between 1 and 1500. The contest duration and the estimated times are given in minutes.
For each test case, print one line in the format Case x: a b c. Here x is the test case number starting from 1, a is the number of solved problems, b is the submission time of the last problem you solve, and c is the total time.
If you cannot solve any problem, print 0 for a, b, and c.
In the first contest of the first example there are 6 problems (A to F) and the contest lasts 100 minutes. The values on the second line are the estimated solving times, so A takes 15 minutes, B takes 23 minutes, and C takes 41 minutes.
The best result in this contest is 5 problems. The last one is submitted at minute 85 and the total time is 228. No time is left for C.