#P10840. 【MX-J2-T1】Turtle and Sequences
【MX-J2-T1】Turtle and Sequences
Background
Original link: https://oier.team/problems/J2B.
Problem Description
You are given a sequence . You can perform some operations on this sequence.
Suppose that before an operation, the sequence length is . In this operation, you may choose an integer such that and , delete , and set the value of to any integer.
Find the maximum number of operations you can perform.
Input Format
The first line contains a positive integer , indicating the initial length of the sequence.
The second line contains positive integers .
Output Format
Output a single non-negative integer in one line, indicating the maximum number of operations.
2
1 2
1
3
1 1 1
0
4
1 1 45 14
3
Hint
Sample Explanation #1
You can choose . After deleting , set to . Now , and no more operations can be performed. Therefore, the answer is .
Sample Explanation #2
No operation can be performed, so the answer is .
Constraints
This problem uses bundled testdata and subtask dependencies are enabled.
| Subtask ID | Points | Special Property | Subtask Dependencies | |
|---|---|---|---|---|
| None | None | |||
| None |
For all testdata, and .
Translated by ChatGPT 5