-->
当前位置:首页 > 题库

PROGRAMMING:Building

Luz5年前 (2021-05-10)题库467
When ZWT was a child, he liked to play with building blocks. However, he often had some messy ideas. For example, he wanted to build a building with a width of N. the building can be regarded as composed of N stone piers with a width of 1. The final height expectation of the I stone pier is Hi.
Before the construction started, there were no stone mounds. Small ZWT, weighing 10kg, has no ability to move dashidun, so he finds FLS who can do magic. FLS tells him that she will help him indirectly fulfill his wish: FLS will increase the height of all stone mounds in the continuous range [l, R] by 1 with one magic wand swing, so as to reach the final desired height.
ZWT got into confusion, so he found a good friend you, please help him to complete his wish, you just need to tell ZWT: FLS needs to wave a few magic wands.
###Input format:
The input contains two lines. The first line contains an integer n, which represents the width of the building.
The second line contains n integers, and the i-th integer is hi.
Tips:
One of the best feasible schemes is to select [1,5] [1,3] [2,3] [3,3] [5,5] in turn
For test data
30%, 1 ≤ n ≤ 10;
70%, 1 ≤ n ≤ 1000;
100%, 1 ≤ n ≤ 100000, 0 ≤ hi ≤ 10000.
###Output format:
Only one line, that is, FLS requires the least number of wand swings.
###Input example:
Sample input 1
```in
five
2 3 4 1 2
```
###Output example:
Sample output 1
```out
five
```







answer:If there is no answer, please comment