#abc217d. D - Cutting Woods
D - Cutting Woods
Score : points
问题描述
我们有一根长度为 米的长木材。
对于每个 ,在距离木材左端 米处有一个标记为 Mark 的记号。
你将收到 个查询请求,其中第 个查询由一对数字 表示。按照 的升序依次处理这些查询,如下所述:
- 若 :在 Mark 处将木材切成两段。
- 若 :选择包含 Mark 的那段木材并输出其长度。
请注意,在处理任一类型的查询(即 或 )时,保证在处理该查询时 Mark 处尚未进行过切割。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a long piece of timber with a length of meters.
For each , there is a mark called Mark at meters from the left end of the piece.
You are given queries, the -th of which is represented as a pair of numbers .
Process the queries in ascending order of as described below.
- If : cut the piece at Mark into two.
- If : choose the piece with Mark on it and print its length.
Here, for both kinds of queries , it is guaranteed that there will have been no cut at Mark when the query is to be processed.
Constraints
- For every , the following holds: there is no such that and .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of lines equal to the number of queries . In the -th line, print the response to the -th such query.
Sample Input 1
5 3
2 2
1 3
2 2
Sample Output 1
5
3
At the time of the first query, no cut has been made, so the piece with Mark has a length of meters. Thus, you should print .
In the second query, the piece is cut into two pieces with lengths of and meters.
At the time of the third query, the piece with Mark has a length of meters, so you should print .
Sample Input 2
5 3
1 2
1 4
2 3
Sample Output 2
2
Sample Input 3
100 10
1 31
2 41
1 59
2 26
1 53
2 58
1 97
2 93
1 23
2 84
Sample Output 3
69
31
6
38
38
update @ 2024/3/10 09:36:57