# P3515 [POI2011]Lightning Conductor

• 364通过
• 1.1K提交
• 题目提供者 洛谷
• 评测方式 云端评测
• 标签 动态规划,动规,dp 斜率优化 POI 2011 高性能
• 难度 省选/NOI-
• 时空限制 1000ms / 128MB
• 提示：收藏到任务计划后，可在首页查看。

## 题目描述

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 to .

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

where denotes the absolute value of the difference between and .

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 .

已知一个长度为n的序列a1,a2,...,an。

对于每个1<=i<=n，找到最小的非负整数p满足 对于任意的j, aj < = ai + p - sqrt(abs(i-j))

## 输入输出格式

输入格式：

In the first line of the standard input there is a single integer () that denotes the number of buildings in Byteburg.

Each of the following lines holds a single integer () that denotes the height of the -th building.

输出格式：

Your program should print out exactly lines to the standard output.

The -th line should give a non-negative integer denoting the minimum height of the lightning conductor on the -th building.

输入样例#1： 复制
6
5
3
2
4
2
4
输出样例#1： 复制
2
3
5
3
5
4

## 说明

已知一个长度为n的序列a1,a2,...,an。

对于每个1<=i<=n，找到最小的非负整数p满足 对于任意的j, aj < = ai + p - sqrt(abs(i-j))

提示
标程仅供做题后或实在无思路时参考。
请自觉、自律地使用该功能并请对自己的学习负责。
如果发现恶意抄袭标程，将按照I类违反进行处理。