QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#8362. game

统计

你最近学习了打隔膜。

有 $n$ 个怪物,击败第 $i$ 个怪物 $A_i$ 点体力,而击败它之后可以获得 $B_i$ 点体力。任意时刻,体力都不能是负数。

对每个 $k = 1, 2, \cdots, n$,试求出击败 $k$ 个怪物至少需要多少初始体力。

输入格式

第一行一个正整数 $n, m$,表示怪物个数。

接下来的 $n$ 行,每行两个整数 $A_i, B_i$,表示怪物的属性。

输出格式

输出一行 $n$ 个非负整数,第 $i$ 个表示击败 $i$ 个怪物所需的最小初始体力。

样例一

input

4
1 2
3 4
1 1
2 3

output

1 2 3 4

样例二

input

8
304 282
773 724
274 481
43 254
813 110
722 107
140 62
351 418

output

43 43 63 63 63 288 341 1044

数据范围与提示

  • 子任务 $1$($5$ 分):$n \leq 16$。

  • 子任务 $2$($27$ 分):$n \leq 7000$。

  • 子任务 $3$($68$ 分):无特殊限制。

对于 $100\%$ 的数据,$1 \leq n \leq 3 \times 10^5$,$1 \leq A_i, B_i \leq 10^9$。

时间限制:$\texttt{2s}$

空间限制:$\texttt{512MB}$

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.