Spacing
English
Language
Contribute a translation- Time limit
- 1000 ms
- Memory limit
- 1024 MB
- Submissions
- 0
- Correct
- 0
- Solved by
- 0
- AC rate
- —
Statement
$N$ students want to stand on a number line. On a number line, a larger number represents a position farther to the right.
The students stand from left to right in order of their numbers, from student $1$ to student $N$, and all positions where the students stand are integers.
Let $B_i$ be the position where student $i$ $(1 \le i \le N)$ stands. The positions where the students stand must satisfy the following conditions.
- For an integer $i$ $(1 \le i \le N)$, student $i$ cannot stand to the right of position $A_i$. In other words, $B_i \le A_i$.
- Every two consecutive students must be at least $K$ units apart. In other words, for an integer $i$ $(1 \le i \le N - 1)$, $B_{i+1} - B_i \ge K$.
When $K = 0$, multiple students may stand at the same position.
The students want to make the position $B_1$ of student $1$ as large as possible.
Among all ways $\left[ B_1, B_2, \cdots, B_N \right]$ for the students to stand on the number line while satisfying the conditions, find a way in which the value of $B_1$ is as large as possible. If there are multiple such ways, output any of them.
It can be proven that there exists at least one way for the students to stand on the number line while satisfying the conditions.
Constraints
- All given numbers are integers.
- $1 \le N \le 100$
- $0 \le K \le 10$
- For an integer $i$ $(1 \le i \le N)$, $1 \le A_i \le 100$.
Subtasks
- (25 points) For an integer $i$ $(1 \le i \le N - 1)$, $A_{i + 1} - A_i \ge K$.
- (35 points) $K = 0$.
- (30 points) There exists a way for the students to stand satisfying the conditions such that $0 \le B_1 \le 100$.
- (10 points) No additional constraints.
Input
The first line contains two integers $N$ and $K$, separated by a space.
The next line contains $N$ integers $A_1, A_2, \cdots, A_N$, separated by spaces.
Output
In the first line, output $N$ integers $B_1, B_2, \cdots, B_N$, separated by spaces. The way $\left[ B_1, B_2, \cdots, B_N \right]$ in which the students stand on the number line must satisfy all the conditions given in the problem statement, and the value of $B_1$ must be maximized.
If there are multiple possible outputs, output any one of them.
Examples
4 0 5 2 7 3
2 2 2 2
5 2 1 4 10 9 13
1 3 5 7 9
4 3 2 1 5 9
-2 1 4 7
Tags
No tags yet