#P16160. [ICPC 2016 NAIPC] Jewel Thief

[ICPC 2016 NAIPC] Jewel Thief

题目描述

The grand museum has just announced a large exhibit on jewelry from around the world. In the hopes of his potential future prosperity, the world-renowned thief and master criminal Edward Terrenando has decided to attempt the magnum opus of his career in thievery.

Edward is hoping to purloin a large number of jewels from the exhibit at the grand museum. But alas! He must be careful with which jewels to appropriate in order to maximize the total value of jewels stolen.

Edward has kk knapsacks of size 1,2,3,,k1, 2, 3, \dots, k, and would like to know for each the maximum sum of values of jewels that can be stolen. This way he can properly weigh risk vs. reward when choosing how many jewels to steal. A knapsack of size ss can hold items if the sum of sizes of those items is less than or equal to ss. If you can figure out the best total value of jewels for each size of knapsack, you can help Edward pull off the heist of the century!

输入格式

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The first line of input will consist of two space-separated integers nn and kk, where nn (1n1,000,0001 \leq n \leq 1,000,000) is the number of jewels in the exhibit, and kk (1k100,0001 \leq k \leq 100,000) is the maximum size of knapsack available to Edward. The next nn lines each will describe a jewel. Each line will consist of two space-separated integers ss and vv, where ss (1s3001 \leq s \leq 300) is the size of the jewel, and vv (1v1091 \leq v \leq 10^9) is its value. Each jewel can only be taken once per knapsack, but each knapsack is an independent problem.

输出格式

Output kk integers separated by whitespace. The first integer should be the maximum value of jewels that will fit in a knapsack of size 11. The second should be the maximum value of jewels in a knapsack of size 22, and so on.

4 9
2 8
1 1
3 4
5 100
1 8 9 9 100 101 108 109 109
5 7
2 2
3 8
2 7
2 4
3 8
0 7 8 11 15 16 19
2 6
300 1
300 2
0 0 0 0 0 0