A knapsack holds total weight at most $W$. There are $N$ items, each with weight $w$ and value $v$, available at most once. Print the maximum total value of a subset whose total weight does not exceed $W$.
Input
First line $N$ and $W$; then $N$ lines each with $w$ and $v$ ($1 \le N \le 100$, $1 \le W \le 10000$, $1 \le w, v \le 100$).
Output
Print the maximum achievable total value.
Example 1
Input
4 5 2 3 1 2 3 3 2 2
Output
7
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.