100 atcoder#ABC116C. [ABC116C] Grand Garden
[ABC116C] Grand Garden
Score : points
Problem Statement
In a flower bed, there are flowers, numbered . Initially, the heights of all flowers are . You are given a sequence as input. You would like to change the height of Flower to for all , by repeating the following "watering" operation:
- Specify integers and . Increase the height of Flower by for all such that .
Find the minimum number of watering operations required to satisfy the condition.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum number of watering operations required to satisfy the condition.
4
1 2 2 1
2
The minimum number of watering operations required is . One way to achieve it is:
- Perform the operation with .
- Perform the operation with .
5
3 1 2 3 1
5
8
4 23 75 0 23 96 50 100
221