0
点赞
收藏
分享

微信扫一扫

Charm Bracelet1.28

金刚豆 2022-01-30 阅读 31
c++

OpenJudge - 7113:Charm Bracelet

描述

Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N(1 ≤ N≤ 3,402) available charms. Each charm iin the supplied list has a weight Wi(1 ≤ Wi≤ 400), a 'desirability' factor Di(1 ≤ Di≤ 100), and can be used at most once. Bessie 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.

输入

Line 1: Two space-separated integers: N and M
Lines 2..N+1: Line i+1 describes charm i with two space-separated integers: Wi and Di

输出

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

样例输入

4 6
1 4
2 6
3 12
2 7

样例输出

23

贝西去了商场珠宝店发现了一个迷人的手镯 ,当然 ,她想要尽可能在 N(1 ≤ N≤ 3,402) 个可用符咒中用最好的符咒填满它.

所提供的列表中的每个魅力都有一个权重Wi(1≤Wi≤400),一个“可取性”因子Di(1≤Di≤100),并且最多只能使用一次。贝茜只能支撑一个重量不超过M(1≤M≤12,880)的魅力手镯。

以权重限制为约束,并给出带有权重和可取性评级的魅力列表,推导出评级的最大可能总和。

输入

第1行:两个用空格分隔的整数:N和M

行2 . .N+1:第i+1行描述符i用两个用空格分隔的整数:Wi和Di

输出

第1行:一个整数,它是给定权重约束下可以实现的魅力愿望的最大总和

举报

相关推荐

0 条评论