#P3515. [POI 2011] Lightning Conductor

    ID: 2584 Type: RemoteJudge 1000ms 125MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>动态规划,dp2011POI凸完全单调性,凸单调

[POI 2011] 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 nn.

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 pp located on the roof of the building ii (of height hih_i) protects the building jj (of height hjh_j) if the following inequality holds:

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

where ij|i - j| denotes the absolute value of the difference between ii and jj.

Byteasar, the mayor of Byteburg, asks your help. Write a program that, for every building ii, determines the minimum height of a lightning conductor that would protect all the buildings if it were put on top of the building ii.

输入格式

In the first line of the standard input there is a single integer nn (1n500,0001\leq n\leq500,000) that denotes the number of buildings in Byteburg. Each of the following nn lines holds a single integer hih_i (0hi1,000,0000\leq h_i\leq1,000,000) that denotes the height of the ii - th building.

输出格式

Your program should print out exactly nn lines to the standard output. The ii - th line should give a non - negative integer pip_i denoting the minimum height of the lightning conductor on the ii - th building.

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