QOJ.ac

QOJ

時間限制: 7 s 記憶體限制: 1024 MB 總分: 100

#6462. 珠宝大盗

统计

大博物馆刚刚宣布要举办一场来自世界各地的珠宝展览。为了实现未来潜在的财富自由,世界闻名的窃贼兼犯罪大师 Edward Terrenando 决定尝试他盗窃生涯中的巅峰之作。

Edward 希望从大博物馆的展览中窃取大量的珠宝。但哎呀!他必须小心选择要窃取的珠宝,以使所窃珠宝的总价值最大化。

Edward 拥有大小分别为 $1, 2, 3, \dots, k$ 的 $k$ 个背包,他想知道对于每个背包,所能窃取的珠宝价值之和的最大值是多少。这样,他在选择窃取多少珠宝时,就能适当地权衡风险与回报。大小为 $s$ 的背包可以装下物品,前提是这些物品的大小之和小于或等于 $s$。如果你能算出每种大小的背包所能装下的珠宝的最大总价值,你就能帮助 Edward 完成这场世纪大劫案!

输入格式

每个输入包含一个测试用例。请注意,你的程序可能会在不同的输入上运行多次。输入的第一行包含两个空格分隔的整数 $n$ 和 $k$,其中 $n$ ($1 \le n \le 1,000,000$) 是展览中珠宝的数量,$k$ ($1 \le k \le 100,000$) 是 Edward 可用的最大背包大小。接下来的 $n$ 行每行描述一颗珠宝。每行包含两个空格分隔的整数 $s$ 和 $v$,其中 $s$ ($1 \le s \le 300$) 是珠宝的大小,$v$ ($1 \le v \le 10^9$) 是其价值。每颗珠宝在每个背包中只能被拿取一次,但每个背包都是一个独立的问题。

输出格式

输出 $k$ 个以空格分隔的整数。第一个整数应该是大小为 $1$ 的背包所能装下的珠宝的最大价值。第二个应该是大小为 $2$ 的背包所能装下的珠宝的最大价值,以此类推。

样例

样例输入 1

4 9
2 8
1 1
3 4
5 100

样例输出 1

1 8 9 9 100 101 108 109 109

样例输入 2

5 7
2 2
3 8
2 7
2 4
3 8

样例输出 2

0 7 8 11 15 16 19

样例输入 3

2 6
300 1
300 2

样例输出 3

0 0 0 0 0 0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.