#abc342b. B - Which is ahead?
B - Which is ahead?
Score: points
问题描述
有 名人员站成一排。站在第 个位置的人是人员 。
执行 个查询操作。第 个查询如下:
- 给定整数 和 。在人员 和人员 之间,输出站在更靠前位置的人员编号。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are people standing in a line. The person standing at the -th position from the front is person .
Process queries. The -th query is as follows:
- You are given integers and . Between person and person , print the person number of the person standing further to the front.
Constraints
- All inputs are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the response for the -th query.
Sample Input 1
3
2 1 3
3
2 3
1 2
1 3
Sample Output 1
2
2
1
In the first query, person is at the first position from the front, and person is at the third position, so person is further to the front.
In the second query, person is at the second position from the front, and person is at the first position, so person is further to the front.
In the third query, person is at the second position from the front, and person is at the third position, so person is further to the front.
Sample Input 2
7
3 7 2 1 6 5 4
13
2 3
1 2
1 3
3 6
3 7
2 4
3 7
1 3
4 7
1 6
2 4
1 3
1 3
Sample Output 2
3
2
3
3
3
2
3
3
7
1
2
3
3
update @ 2024/3/10 01:35:56