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.


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 i-th line contains two integers: the costs c (1 ≤ c ≤ 50) and the benefit value v (1 ≤ v ≤ 10000) of the i-th 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.


For each output, print the maximum benefit value reachable with 1 digit after the decimal point. Then print k integers with i-th 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.


2 1 5
3 5
3 5 20
2 5
18 6
1 1
3 3
2 3
0 0 0


1 5 1 

hide comments
namitp: 2017-07-07 11:13:02

Very Nice Problem.....
Finally Nailed it after so many wrong answers....

tsioftas: 2016-08-30 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: 2016-08-30 18:11:34
Sudharsansai: 2015-03-10 17:06:32

Finally AC (after loads of WA :( )...By the way , Thanks 'Adrian Kuegel' for once again providing an interesting problem...
And that completes my 150th classical :)

Last edit: 2015-03-10 17:08:17
parimala rangan: 2014-12-14 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: 2014-12-14 04:40:07
Piotr KÄ…kol: 2014-12-13 19:41:12

One smaller test was added with the same time limit and all submissions were rejudged (with author's consent).
Special thanks to Aditya Paliwal and parimala rangan for informing about this issue!

Aditya Paliwal: 2014-11-29 22:38:17

Yeah parimala is right, test cases are weak.

parimala rangan: 2014-11-22 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: 2014-10-07 14:38:55

Great problem, learned a lot.

Aditya Paliwal: 2014-10-07 02:03:56

finally AC!

Last edit: 2014-10-13 20:51:50
besher massri: 2014-08-02 19:31:08

nice problem ... AC in the first GO :)

Added by:Adrian Kuegel
Time limit:0.702s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Resource:own problem