2585. 0-1 Package

单点时限: 2.0 sec

内存限制: 256 MB

Partychen has gone to the mall’s jewelry store and spies a charm bracelet. Of course, he’d like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supplied list has a weight Wi (1 ≤ Wi ≤ 400), a ‘desirability’ factor Di (1 ≤ Di ≤ 100), and can be used at most once. partychen can only support a charm bracelet whose weight is no more than M (1 ≤ M ≤ 12,880).

Given that weight limit as a constraint and a list of the charms with their weights and desirability rating, deduce the maximum possible sum of ratings.

输入格式

The first line are two space-separated integers: N and M

The next N lines describes charm i with two space-separated integers: Wi and Di

输出格式

A single integer that is the greatest sum of charm desirabilities that can be achieved given the weight constraints

样例

Input
4 6
1 4
2 6
3 12
2 7
Output
23
Hint:
We choose 1 4,2 7,3 12,we can get the greatest sum 23.and the weight is 6.

142 人解决,186 人已尝试。

176 份提交通过,共有 521 份提交。

3.1 EMB 奖励。

创建: 16 年,11 月前.

修改: 7 年,2 月前.

最后提交: 1 月,4 周前.

来源: partychen

题目标签
DP