An expedition has found n artifacts, artifact i weighing w_i and worth
v_i. Your bag can carry a total weight of at most W. Each artifact can
either be taken whole or left behind (no partial artifacts). Maximize the
total value you can carry.
Line 1: two integers n W (1 ≤ n ≤ 500, 0 ≤ W ≤ 10^4)
Next n lines: two integers w v (1 ≤ w ≤ 10^4, 1 ≤ v ≤ 10^4)
A single integer: the maximum achievable total value.
Input:
4 7
2 3
3 4
4 5
5 6
Output:
9
Case 1
4 7 2 3 3 4 4 5 5 6
9
Case 2
3 50 10 60 20 100 30 120
220
Input
4 7 2 3 3 4 4 5 5 6
Expected Output
9
Run or submit your code to see output here.