| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 128 MB | 151 | 104 | 85 | 75.221% |
You have a transport plane that has to deliver items to a remote location. You would like to load all the items on the plane, but you can not exceed the plane’s weight capacity, W. Given n items of known weights w1, w2, …, wn and values v1, v2, …, vn find the most valuable subset of the items that fit into the plane without exceeding the capacity, W.
The first line of input will be a positive integer indicating the number of problem sets. Each problem set will start with a line that has two positive integers, n and W, where n is the number of items and W is the capacity of the plane. The next n lines will have two integers, w and v, where w is the weight and v is the value of the item. All weights and values will be positive integers, and the number of items in any problem set will be no more than 20.
For each problem set print, on a separate line, the total value of the most valuable subset that the plane can transport without exceeding its capacity W.
2 3 5 2 3 2 2 3 3 4 10 7 42 3 12 4 40 5 25
6 65