#t390. 0/1背包
0/1背包
0/1 Knapsack
Problem Background
Special for beginners, ^_^
Problem Description
A traveller has a backpack with a maximum capacity of kilograms. Now there are items, whose weights are and whose values are . Each item can be taken at most once. What is the maximum total value the traveller can obtain?
Input Format
Line : two integers, (backpack capacity, ) and (number of items, ).
Lines : each line has integers , the weight and value of each item.
Output Format
A single line containing one number: the maximum total value.
Sample Input
10 4
2 1
3 3
4 5
7 9
Sample Output
12
Constraints
1s, 1024KiB for each test case.