#P6304. [eJOI 2018] 山
[eJOI 2018] 山
Description
There are mountains in the city of Innopolis. The height of the -th mountain is .
For beauty, you can build a house on a mountain only if it is strictly higher than the mountains on both sides of it (if they exist).
There is an excavator. Each hour, it can decrease the height of any one mountain by . At the same time, the excavator can work on only one mountain. A mountain’s height can be reduced to or negative.
For each , find the minimum number of hours the excavator needs to work in order to build houses (that is, to make at least mountains satisfy the condition above).
Input Format
The first line contains one integer .
The second line contains integers , representing the sequence .
Output Format
Output one line with integers. The -th integer is the answer when .
5
1 1 1 1 1
1 2 2
3
1 2 3
0 2
5
1 2 3 2 2
0 1 3
Hint
[Explanation for Sample 1]
Decrease the height of mountain by . The heights become . Now mountain satisfies the condition.
Then decrease the height of mountain by . The heights become . Now mountains satisfy the condition.
[Constraints]
For of the testdata, , .
| Subtask ID | Score | Constraints |
|---|---|---|
| Sample | ||
| No special constraints |
Source: eJOI2018 Problem A “Hills”.
Note: The translation is from LOJ.
Translated by ChatGPT 5
京公网安备 11011102002149号