LIGHTIN - Lightning Conductor
Progressive climate change has forced the Byteburg authorities to build a huge lightning conductor that would protect all the buildings within the city. These buildings form a row along a single street, and are numbered from 1 to n.
The heights of the buildings and the lightning conductor are non-negative integers. Byteburg's limited funds allow construction of only a single lightning conductor. Moreover, as you would expect, the higher it will be, the more expensive.
The lightning conductor of height p located on the roof of the building i (of height hi) protects the building j (of height hj) if the following inequality holds:
hj <= hi + p - sqrt(abs(i-j))
where |i-j| denotes the absolute value of the difference between i and j.
Byteasar, the mayor of Byteburg, asks your help. Write a program that, for every building, determines the minimum height of a lightning conductor that would protect all the buildings if it were put on top of the building i.
Input
In the first line of the standard input there is a single integer n (1 <= n <= 500,000) that denotes the number of buildings in Byteburg. Each of the following n lines holds a single integer hi (1 <= hi <= 1,000,000,000) that denotes the height of the i-th building.
Output
Your program should print out exactly n lines to the standard output. The i-th line should give a non-negative integer pi denoting the minimum height of the lightning conductor on the i-th building.
Example
For the input data:
6 5 3 2 4 2 4
the correct result is:
2 3 5 3 5 4
hide comments
jack98:
2024-09-29 11:04:34
Can the administrator
|
|
nadstratosfer:
2019-12-13 06:15:19
Buildings are numbered from 1 to n.
|
|
David:
2019-06-26 19:45:03
Images not displayed. |
Added by: | Krzysztof Lewko |
Date: | 2011-06-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | XVIII POI |