Lightning Conductor
Time limit1sMemory limit128 MB
For each building i, find the smallest integer p such that h_i + p - sqrt(|i-j|) >= h_j for every building j.
- Level
Hard8 of 10
- Topics
- Divide and conquer, Dynamic programming, Math
- Solved
- No attempts yet
Problem
Worsening climate change has forced the city of Byteburg to build one large lightning conductor that protects every building in the city. The buildings stand in a single row along one street and are numbered from to .
The heights of the buildings and of the lightning conductor are non-negative integers. The budget allows only a single lightning conductor to be built, and, as you would expect, the taller it is, the more it costs.
A lightning conductor of height placed on the roof of building (whose height is ) protects building (whose height is ) exactly when
where is the absolute difference of the two building numbers.
For every building , determine the smallest height of a lightning conductor that, placed on top of building , would protect all of the buildings.
Input
The first line contains a single integer (), the number of buildings.
Each of the next lines contains a single integer (), the height of the -th building.
Output
Print exactly lines. The -th line must contain one non-negative integer : the minimum height of a lightning conductor placed on the -th building that protects every building.