loj#P3468. 「JOI 2021 Final」有趣的家庭菜园 4
「JOI 2021 Final」有趣的家庭菜园 4
Description
Bitaro likes gardening. He is now growing plants called Biba-herbs in the garden. There are Biba-herbs in the garden, planted in a line from the west to the east. The Biba-herbs are numbered from to from the west to the east. Now, the height of the Biba-herb () is .
Due to the breed improvement, if Bitaro waters a Biba-herb once, then its height increases by . Since he wants to decorate the garden, he will water the Biba-herbs several times so that the following condition is satisfied.
- After Bitaro finishes watering, let be the height of the Biba-herb . Then, there exists an integer () such that holds for every , and holds for every .
However, Bitaro is not good at watering. When he waters Biba-herbs, he can only water consecutive Bibaherbs in an interval. In other words, he chooses integers and () and waters the Biba-herbs .
Bitaro wants to minimize the number of times of watering.
Write a program which, given the number of Biba-herbs and their current heights, calculates the minimum number of times of watering so that the above condition is satisfied.
Input
Read the following data from the standard input. Given values are all integers.
Output
Write one line to the standard output. The output should contain the minimum number of times of watering.
5
3 2 2 3 1
3
5
9 7 5 3 1
0
2
2021 2021
1
8
12 2 34 85 4 91 29 85
93
Constraints
- .
- ().
Subtasks
- ( points) .
- ( points) No additional constraints.