#P5503. [JSOI2016] 灯塔

[JSOI2016] 灯塔

Problem Description

Along the border of JSOI, there are NN consecutive mountain peaks. The height of the ii-th peak is hih_i. For simplicity, we assume these NN peaks are arranged along a straight line.

If a lighthouse of height pp (p0p \ge 0) is built on the ii-th peak, JYY finds that this lighthouse can illuminate the jj-th peak if and only if the following inequality holds:

hjhi+pijh_j \le h_i + p - \sqrt {|i-j|}

The king of JSOI wants JYY to provide, for each peak, the minimum height required to build a lighthouse that can illuminate all other peaks. Can you help JYY?

Input Format

The input contains one line with a positive integer NN.

In the next NN lines, the ii-th line contains a positive integer hih_i, representing the height of the ii-th peak.

Output Format

The ii-th line contains a non-negative integer, representing the minimum height pip_i required to build a lighthouse on the ii-th peak.

6
5
3
2
4
2
4
2
3
5
3
5
4

Hint

For 100%100\% of the data, 1<N1051 < N \le 10^5, 0<hi1090 < h_i \le 10^9.

Translated by ChatGPT 5