#P475. 【例86.2】 01背包问题
【例86.2】 01背包问题
Description
A traveler has a backpack that can hold at most kilograms. There are items available, with weights , , ..., and values , , ..., . Find the maximum total value the traveler can obtain.
Input Format
The first line contains two integers: (backpack capacity, ) and (number of items, ).
Lines to each contain two integers and , representing the weight and value of each item.
Output Format
A single line containing one number, representing the maximum total value.
Sample
10 4
2 1
3 3
4 5
7 912