QTGIFT2 - Valentine knapsack
English | Vietnamese |
Today is Valentine, and DB has give very much chocolate from his schoolmate. He is so happy, but his bag is not enough big to take all the chocolate bars to home. So he decides that he will take the maximum weight of chocolate as possible.
Please help him find the best way to select chocolate bars. Note that his bag can contains at most c(g) chocolate and he mustn’t crack any chocolate bar because it will make his bag dirty.
Input :
- First line contains two positive integer : n and c, the number of chocolate bars and the maximum weight of chocolate his bag can contains.
- Second line contains n positive integer, the i-th number denotes the weight of the i-th chocolate bar.
Output :
- First line : two numbers, x and k, is the proposed maximum weight he can take and the number of chocolate bars he need to select.
- Second line : k numbers, are indexes of the chocolate bars he need to select.
Limits :
- 1 ≤ n ≤ 105
- 1 ≤ c ≤ 109
- 1 ≤ w[i] ≤ 104
Scoring :
There are 30 test cases. With any test case, let xmax is the best result and x is your program’s result, your score will calculate by function : max(0, 10 – [(xmax – x) / log10xmax]), where [a] denotes the smallest integer that not less than a.
Sample :
Input :
6 100
26 15 69 24 45 90
Output :
95 2
1 3
In above test case :
- If your program output :
95 3
1 5 4
You will get 10 points.
- If your program output :
90 1
6
You will get max(0, 10 – (95 – 90) / log1095) = 7 points.
- If your program output :
95 2
1 2
You will get… 0 point !
hide comments
|
Mitch Schwartz:
2014-02-21 14:16:46
1) Suggest changing "maximum weight he can take" -> "proposed maximum weight he can take".
|
Added by: | Coder nhà mình |
Date: | 2014-02-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |