Time limit: 20000ms single point time limit: 1000ms memory limit: 256MB description
Say then last week's story, Small hi and small ho struggled to finally get the vast number of lottery tickets! And now, it's time for Little Ho to pick up the reward!
Small Ho now has M-ticket, and the prize area has n prizes, respectively labeled 1 to N, of which the first prize of the need (i) to redeem the lottery, but also can only redeem once, in order to make the hard-won lottery not wasted, small ho to each of the prizes are assessed points, The score value of the prize for the I-item is value (i), which indicates his preference for the prize. Now he wants to know which prizes can be changed by virtue of the lotteries in his hand, so that the sum of the prizes ' preferences can be maximized.
Tip One: Reasonable abstract problem, define state is the most critical step in dynamic planning
Hint two: said to reduce the time consumption, let's see how to reduce the space consumption
Input
Each test point (input file) has and has only one set of test data.
The first act of each set of test data is two positive integers n and m, indicating the number of prizes, and the number of lotteries in small Ho's hands.
The next n lines describe each line describing a prize, where I behaves two integers need (i) and value (i), meaning as described earlier.
Test Data Assurance
For 100% of data, the value of n does not exceed the value of 500,m no more than 10^5
For 100% of data, need (i) does not exceed 2*10^5, value (i) does not exceed 10^3
Output
For each set of test data, output an integer ans that represents the total preference value that small ho can get.
-
Sample input
-
5 1000144 990487 436210 673567 581056 897
-
Sample output
-
2099
[01 Backpack]hihocoder_1038_01 Backpack