Processing math: 100%
Knapsack 5 - MarisaOJ: Marisa Online Judge

Knapsack 5

Time limit: 1000 ms
Memory limit: 256 MB
There are n items, ith item has the weight of wi and value of vi. You can choose an arbitrary number items as long as their weight doesn't exceed a given S. Find a way of choosing items so that their value is maximum possible. ### Input - First line contains 2 integers n and S. - Each line in the next n line contains 2 integers wi, vi. ### Output - The first contains the maximum possible value you can obtain and k, the number of the selected items. - The second line contains k integers, the indices of the selected items, can be in any order. ### Constraints - 1≤n≤100,S≤1012. - 1≤wi,vi≤1012. ### Example Input: 3514412100 Output: 104213 ### Scoring - All test cases are scored equally. - Consider the jury's answer as Y and your answer as X. - If X≥Y, you receive a score of 100 for test case. - If 1<YX≤1.5, your score for the test case is calculated as (3X−2YX)5×100. - If YX>1.5, you receive a score of 0 for the test case.