luogu#P5069. [Ynoi Easy Round 2015] 纵使日薄西山
[Ynoi Easy Round 2015] 纵使日薄西山
Background
【You seem very happy.】
Because I rarely get a chance to go out alone with you.
Or rather, it seems like we never really had before, right?
【Didn’t we go to lots of places together when we first met?】

Huh? Ah... right.
But, well... it just feels kind of different from now.
Alright, hurry up, let’s go!
【Chtholly...】


Seriously, don’t make a sound like you’re about to cry. You’re an adult, aren’t you?
I’m fine, look.
Eh...
Ah, th-this kid is also fine.

【If anything unexpected happens, I...】
【I thought I would lose you again, this close...】


A red-haired girl.
Is
Watching here.
Problem 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