QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#18113. 湖畔牛迟到的原因 3

統計

历经波折,Hobanwoo 终于到达了起始之村前,但通往悬崖上村庄的阶梯因怪物的袭击而损毁,他决定用圆木来制作阶梯。

他将圆木垂直并排竖立以制作阶梯。在此过程中,怪物会不时使用威力为 $m$ 的魔法,以当前已竖立的圆木中最长圆木的长度 $k$ 为基准,将所有长度大于等于 $\max(k-m, 0)$ 的圆木长度变为 $\max(k-m, 0)$。

给定 $N$ 个查询。

1 a:Hobanwoo 在阶梯旁竖立一根长度为 $a$ 的圆木。 2 m:怪物对阶梯使用威力为 $m$ 的魔法。

为了制作阶梯,Hobanwoo 新竖立的圆木长度总是比之前通过 1 号查询竖立的圆木长度要长。

为了加固阶梯,请计算在 $N$ 个查询结束后,完成的阶梯中所有圆木长度的总和。

输入格式

第一行给定查询的个数 $N$。 从第二行开始的 $N$ 行中,每行给定两个正整数 $x$ 和 $y$,中间用空格隔开。 若 $x$ 为 1,表示 Hobanwoo 在阶梯旁竖立了一根长度为 $y$ 的圆木,且新竖立的圆木长度总是比之前通过 1 号查询竖立的圆木长度要长。 若 $x$ 为 2,表示怪物对阶梯使用了威力为 $y$ 的魔法,即使在没有阶梯的状态下也可能输入 2 号查询。 ($1 \le N \le 500\,000$) ($1 \le x \le 2$) ($1 \le y \le 10^9$)

输出格式

输出 $N$ 个查询结束后,完成的圆木阶梯中所有圆木长度的总和。

样例

输入 1

1
1 1000000000

输出 1

1000000000

输入 2

1
2 1000000000

输出 2

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.