#P5069. [Ynoi Easy Round 2015] 纵使日薄西山
[Ynoi Easy Round 2015] 纵使日薄西山
Description
Chtholly wants you to maintain a positive integer sequence of length , , supporting updates that modify the value at some position.
After each update, you are asked: if we repeatedly perform the following operation on the sequence, how many operations are needed to make the sequence become all (after the query, the sequence is the same as before the query; it will not actually become all )?
Choose a position where the maximum value in the sequence occurs. If there are multiple maximum values, choose the one with the smallest index. Let the position be . Then decrease by . If there exists a number less than in the sequence, change that number to .
Input Format
The first line contains an integer .
The next lines each contain one integer .
The next line contains an integer .
The next lines each contain two integers separated by a space, meaning to modify to .
Output Format
Output lines, each containing one integer representing the answer.
4
3
6
6
4
3
4 4
3 5
1 8
10
10
13
Hint
Idea: ccz181078, Solution: ccz181078, Code: ccz181078, Data: ccz181078
Constraints: , , .
Translated by ChatGPT 5
京公网安备 11011102002149号