#P17192. [KOI 2026 #2] 拉开距离
[KOI 2026 #2] 拉开距离
Problem Description
There are students who will stand on a number line. On the number line, a larger value means a position further to the right.
The students stand from left to right in order of their indices from to , and all positions must be integers.
Let the position of student () be . The positions must satisfy the following conditions:
- For each integer (), student cannot stand to the right of position . That is, must hold.
- Any two adjacent students must be at least apart. That is, for each integer (), must hold.
When , multiple students may stand at the same position.
The students want to make the position of student as large as possible.
Find a standing plan that satisfies all conditions and maximizes the value of . If multiple plans exist, output any one of them.
It can be proven that at least one valid standing plan exists.
Input Format
The first line contains two integers and separated by spaces.
The second line contains integers separated by spaces.
Output Format
Output integers separated by spaces on the first line. The standing plan must satisfy all conditions in the statement, and the value of must be maximized.
If multiple valid outputs exist, any one of them will be accepted.
5 2
1 4 10 9 13
1 4 6 9 12
4 0
5 2 7 3
2 2 3 3
4 3
2 1 5 9
-2 1 5 8
Hint
Constraints
- All given numbers are integers.
- .
- .
- For each integer (), .
Subtasks
- ( points) For each integer (), .
- ( points) .
- ( points) Among all standing plans that satisfy the conditions, there exists a plan with .
- ( points) No additional constraints.
Translated by ChatGPT-5.6.
Translated by ChatGPT 5