#P5324. [BJOI2019] 删数
[BJOI2019] 删数
Description
For any sequence, if it can be deleted into an empty sequence after performing the following delete operation a finite number of times, then the sequence is said to be deletable to empty.
One delete operation is defined as follows:
Let the current sequence length be . Then delete all numbers in the sequence that are equal to .
Now there is a sequence of length , and there are modification operations. After the -th modification, you need to answer: For the sequence after modifications, what is the minimum number of elements that still need to be changed so that it can be deleted to empty?
Each modification is either a point update, or adding to the whole sequence, or subtracting from the whole sequence.
Input Format
The first line contains two positive integers , representing the sequence length and the number of modifications.
The second line contains positive integers, representing the sequence . That is, the -th input number is the -th element of the sequence, .
The next lines each contain two integers , representing one modification operation. When , this operation is a point update: set the -th number in the sequence, , to . When , this operation adds to the whole sequence.
Output Format
Output lines, each containing one integer. The -th line denotes the answer after the first modifications.
3 9
1 2 3
1 1
0 1
0 1
0 1
2 2
3 2
0 -1
0 -1
0 -1
0
1
2
3
2
1
1
2
2
Hint
Sample Explanation (partial): After the first modification, the sequence is , and it can be deleted to empty without any changes. After the fourth modification, the sequence is , and all three numbers must be changed before it can possibly be deleted to empty. After the sixth modification, the sequence is , and changing the first number to makes it deletable to empty. After the ninth modification, the sequence is , and you can change the second number to and the third number to to make it deletable to empty.
Constraints: For of the testdata:
- , , .
- When , .
- When , .

Translated by ChatGPT 5
京公网安备 11011102002149号