MENU  Menu
Alfred wants to plan what to cook in the next days. He can cook various dishes. For each dish the costs of the ingredients and the benefit value is known. If a dish is cooked the second time in a row, the benefit value for the second time is 50 percent of the benefit value of first time, if it is prepared for the third or higher time in a row, the benefit value is 0. For example cooking a dish with benefit value v three times in a row leads to a total benefit value of 1.5*v.
Help him to build the menu which maximizes the benefit value under the constraint that his budget is not exceeded.
Input
The input consists of several test cases. Each test case begins with 3 integers in a line: The number of days k (1 ≤ k ≤ 21) Alfred wants to plan for, the number of dishes n (1 ≤ n ≤ 50) he can cook and his budget m (0 ≤ m ≤ 100).
The following n lines describe the dishes Alfred can cook. The ith line contains two integers: the costs c (1 ≤ c ≤ 50) and the benefit value v (1 ≤ v ≤ 10000) of the ith dish.
The end of the input is signaled by a test case with k = n = m = 0. You don't need to process this test case.
Output
For each output, print the maximum benefit value reachable with 1 digit after the decimal point. Then print k integers with ith integer being the number of the dish to cook on day i. Dishes are numbered from 1 to n. Print at least one space or new line character after each integer.
If there are several possible menus reaching the maximum benefit value, select the one with minimum costs, if there are several with minimum costs, you can print any of them.
If every menu exceeds the budget, print only the benefit value of 0.
Example
Input: 2 1 5 3 5 3 5 20 2 5 18 6 1 1 3 3 2 3 0 0 0 Output: 0.0 13.0 1 5 1
hide comments
sharjeel_spoj:
20201014 20:50:43
Some test cases with answers , hope it helps.


namitp:
20170707 11:13:02
Very Nice Problem.....


tsioftas:
20160830 09:17:54
I am getting WA even though my code finds the correct answer to the sample test data and some other random test cases I tested. Can someone help by uploading another, strong, test case? Last edit: 20160830 18:11:34 

Sudharsansai:
20150310 17:06:32
Finally AC (after loads of WA :( )...By the way , Thanks 'Adrian Kuegel' for once again providing an interesting problem...


parimala rangan:
20141214 04:26:23
Thank you for accepting my test cases. There is a great corner case which I think many would have missed. Thanks admin for listening to the query. Last edit: 20141214 04:40:07 

Piotr KÄ…kol:
20141213 19:41:12
One smaller test was added with the same time limit and all submissions were rejudged (with author's consent).


Aditya Paliwal:
20141129 22:38:17
Yeah parimala is right, test cases are weak. 

parimala rangan:
20141122 00:30:33
I have a test case with me for which my friend's code which got AC when submitted here, failed. How can I contact the problem setter personally without posting the test case publically? 

Dario Pavlovic:
20141007 14:38:55
Great problem, learned a lot. 

Aditya Paliwal:
20141007 02:03:56
finally AC! Last edit: 20141013 20:51:50 
Added by:  Adrian Kuegel 
Date:  20050704 
Time limit:  0.702s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 
Resource:  own problem 