#P2871. [USACO07DEC] Charm Bracelet S

    ID: 1914 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>动态规划,dp2007USACO枚举,暴力背包

[USACO07DEC] Charm Bracelet S

Description

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(1N3,402)N (1 \le N \le 3,402) available charms. Each charm i in the supplied list has a weight Wi(1Wi400)W_i (1 \le W_i \le 400), a 'desirability' factor Di(1Di100)D_i (1 \le D_i \le 100), and can be used at most once. Bessie can only support a charm bracelet whose weight is no more than M(1M12,880)M (1 \le M \le 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.

Input Format

  • Line 11: Two space-separated integers: NN and MM.

  • Lines 2N+12 \sim N+1: Line i+1i+1 describes charm ii with two space-separated integers: WiW_i and DiD_i.

Output Format

  • Line 11: 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