落块AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)There are $N$ cells arranged in a row from left to right. Initially, no blocks are placed in any cell.
有 $N$ 个格子从左到右排成一行。初始时,每个格子中都没有方块。AI (CI翻译)
You are given $Q$ queries, so process them in order. Each query is one of the following two types:
给定 $Q$ 个查询,请按顺序处理。每个查询属于以下两种类型之一:AI (CI翻译)
1 x: Place$1$block in the$x$-th cell from the left. Then, if every cell has at least$1$block, remove$1$block from every cell.2 y: Output the number of cells that have at least$y$blocks.
1 x:在从左数第$x$个格子中放入$1$个方块。然后,如果每个格子中都至少有$1$个方块,就从每个格子中移除$1$个方块。2 y:输出至少有$y$个方块的格子数量。
Constraints
约束条件
AI (CI翻译)$1 \leq N \leq 3 \times 10^5$$1 \leq Q \leq 3 \times 10^5$$1 \leq x \leq N$$1 \leq y \leq 3 \times 10^5$- All input values are integers.
- At least one query of the second type exists.
$1 \leq N \leq 3 \times 10^5$$1 \leq Q \leq 3 \times 10^5$$1 \leq x \leq N$$1 \leq y \leq 3 \times 10^5$- 所有输入值均为整数。
- 至少存在一个第二种类型的查询。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入中给出,格式如下:AI (CI翻译)
N Q
\mathrm{query}_1
\mathrm{query}_2
\vdots
\mathrm{query}_Q
N Q
\mathrm{query}_1
\mathrm{query}_2
\vdots
\mathrm{query}_QAI (CI翻译)
Each query $\mathrm{query}_i$ $(1 \leq i \leq Q)$ is given in one of the following formats:
每个查询 $\mathrm{query}_i$ $(1 \leq i \leq Q)$ 的格式为以下两种之一:AI (CI翻译)
1 x
1 xAI (CI翻译)
2 y
2 yAI (CI翻译)
Output
输出格式
AI (CI翻译)Let $K$ be the number of queries of the second type. Output $K$ lines. The $i$-th line $(1 \leq i \leq K)$ should contain the answer to the $i$-th query of the second type.
设第二种类型的查询有 $K$ 个。输出 $K$ 行。第 $i$ 行 $(1 \leq i \leq K)$ 应包含第 $i$ 个第二种类型查询的答案。AI (CI翻译)
样例
3 7
1 1
1 3
1 3
2 1
2 2
1 2
2 1
2
1
1
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。