0/1 Knapsack
You have items with weights and values and a bag that holds weight at most . Each item can be taken at most once. Maximise the total value.
Input
and , then lines weight value.
Output
The maximum value.
Constraints
,
Sample 1
Input
3 4 1 15 3 20 4 30
Output
35