#BS0000072. Khỉ và chiếc thang trơn (The Monkey and the Oiled Bamboo)
Khỉ và chiếc thang trơn (The Monkey and the Oiled Bamboo)
The Monkey and the Oiled Bamboo
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Rungs are at strictly increasing heights . Start at height 0 with integer strength . A jump larger than current strength fails; a jump exactly equal to it succeeds and then decreases strength by one; a smaller jump leaves strength unchanged. Find the minimum initial .
Input
The first line contains . The second line contains rung heights.
Output
Print the minimum initial strength.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: , .
Example
Input
5
1 6 7 11 13
Output
5
Explanation
Strength 5 handles jumps 1,5,1,4,2 with decrements after exact jumps.