Problem list
Log in
#r03333 · Online Judge > GoldOJ

0/1 Knapsack

Gold IV 2.0 s 256 MB

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
Source
Online Judge > GoldOJ
Appears in
Not part of a ladder, contest or set yet.
Accepted 2 Submissions 2 Acceptance 100% Solvers 2

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code