F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Harry Potter and the Present

Time 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
2 2 2 3 4 1 1 2 1 2 3 2 3 3 4 1 1 2 1 2 3
 

Sample Output
Case 1: 2 2 3 5 Case 2: 3 3 3 6
 

Author
iSea@WHU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-26 18:09:27, Gzip enabled