|
||||||||||
Harry Potter and the PresentTime Limit: 20000/20000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 248 Accepted Submission(s): 22 Problem Description Hogwarts is welcoming the new term! After Voldemort and the Death Eater were wiped out by Harry Potter and his friends, Harry becomes the glory of the Wizarding World, magician treat him as model, hero, king¡ and much more than that. So on the ceremony held to signal the beginning of a new school semester, they decide to invite Harry Potter and his three friends: Ginny, Ron and Hermione. Back to their Alma Mater, Harry and his three friends find a store to purchase some present. They can use at most M units of money, what¡¯s more, they don¡¯t have enough energy to take the presents to Hogwarts if their total weight is exceeding W or the total number is exceeding S. In the store, there are N kinds of present, each of them has price Pi, weight Wi, and value Vi, and as it¡¯s a magical world, any present¡¯s amount is infinite and can be purchased for many times. Unfortunately, all of them have different idea to buy the gifts. Ginny wants the total number to be the largest, while Ron thinks the more money they cost, the more sincerity there will be shown, Harry wonders the biggest weight they can take because he always likes to challenge himself, Hermione, of course, is already beginning to calculating the biggest value. Here you see, your task is very simple, calculating the four numbers. Input The first line contains a single integer T, indicating the number of test cases. Each test case begins with four integers N, S, W, M. Then N lines following, each line contains three integers Pi, Wi, Vi, describing a present. Technical Specification 1. 1 <= T <= 100 2. 1 <= N <= 1 000 3. 1 <= S <= 1 000 000 000 4. 0 <= Wi, Pi, W, M <= 1 000 5. 0 <= W*M <= 1 000 6. 0 <= Vi <= 1 000 000 Output For each test case, output the case number first, then four integers, indicating Ginny¡¯s, Ron¡¯s, Harry¡¯s and Hermione¡¯s answer, separated them by a blank. Their meaning should be the same with the description. Sample Input
Sample Output
Author iSea@WHU Source | ||||||||||
|