| UDESC Selection Contest 2024-1 |
|---|
| Закончено |
Commander Rosso, renowned for his precise and safe landings, finds himself in a critical situation in the middle of the void of space during yet another mission. An unexpected solar storm interrupts his exploration mission, damaging the navigation systems of his ship, the Geometric Voyager, and forcing an emergency landing on the remote planet JOI-47.
The terrain of JOI-47 is notoriously uneven: there is a chain of kilometer-high mountains and only a small strip of land where the ship can land, located beyond the mountains.
Upon entering the planet's dense atmosphere, Rosso must carefully adjust the initial descent altitude of the Geometric Voyager, as the ship's automated altitude control system causes it to descend at a constant rate of one kilometer per second. Each second of descent corresponds to one kilometer of forward movement toward the landing strip. Since the available landing strip is short, Rosso wants to choose the smallest possible initial altitude that avoids all the mountains. The ship avoids a mountain if its altitude is strictly greater than the mountain's height when passing over it.
In the example above, the smallest initial altitude required to pass over the mountains is 5; if the initial altitude were lower, the ship would collide with the first or second mountain. The mountains have heights $$$[2, 2, 1]$$$ and the ship will have altitudes $$$[4, 3, 2]$$$ while passing over the mountains. Note that the height of the Geometric Voyager is measured by the number of squares below it, and when the ship is landed, its height is zero.
You are Rosso's co-pilot and he wants to test whether you are fit to pilot the Geometric Voyager alone. Mistakes are not an option, as a poorly calculated initial altitude could cause the ship to crash into the mountains or fail to land in time. Given the heights of the $$$N$$$ mountains, report the ideal height to enter the landing course.
The first line of input consists of an integer $$$N$$$ $$$(1 \le N \le 10^5)$$$, the number of mountains between Rosso's ship and the landing strip.
The second line contains $$$N$$$ integers $$$h_1, h_2, \cdots , h_N$$$ $$$(1 \le h_i \le 10^9)$$$, where $$$h_i$$$ represents the height of the $$$i$$$-th mountain.
The output must contain a single integer, representing the smallest initial altitude (in kilometers) required to enter the landing course without colliding with any mountain.
32 2 1
5
110
12
53 4 2 3 1
8
| Название |
|---|


