#Z01534. 完全背包

完全背包

题目描述

有 Nlns="http://www.w3.org/1998/Math/MathML">� 种物品和一个容量是 Vlns="http://www.w3.org/1998/Math/MathML">� 的背包,每种物品都有无限件可用。

第 ilns="http://www.w3.org/1998/Math/MathML">� 种物品的体积是 vilns="http://www.w3.org/1998/Math/MathML">��,价值是 wilns="http://www.w3.org/1998/Math/MathML">��。


求解将哪些物品装入背包,可使这些物品的总体积不超过背包容量,且总价值最大。

输出最大价值。

输入格式

第一行两个整数,N,Vlns="http://www.w3.org/1998/Math/MathML">�,�,用空格隔开,分别表示物品种数和背包容积。

接下来有 Nlns="http://www.w3.org/1998/Math/MathML">� 行,每行两个整数 vi,wilns="http://www.w3.org/1998/Math/MathML">��,��,用空格隔开,分别表示第 ilns="http://www.w3.org/1998/Math/MathML">� 种物品的体积和价值。

输出格式

输出一个整数,表示最大价值。

4 5
1 2
2 4
3 4
4 5
10

提示

数据范围

0lns="http://www.w3.org/1998/Math/MathML">0�,�≤1000

0