利用单调性dp
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cmath>
#define maxn 500021
using namespace std;
int n,a[maxn];
double f[2][maxn];
struct node{
int x,l,r;
node(int a=0,int b=0,int c=0):x(a),l(b),r(c){}
}q[maxn];
double calc(int x,int y){return a[x]-a[y]+sqrt(abs(y-x));}
int find(node p,int x){
int l=p.l,r=p.r,id=p.x;
while(l<r){
int mid=l+r>>1;
if(calc(id,mid)>calc(x,mid))l=mid+1;
else r=mid;
}return l;
}
void solve(int id){
int s=1,t=0;
for(int j,i=1;i<=n;i++){
q[s].l++;
while(s<=t&&q[s].l>q[s].r)s++;
f[id][i]=calc(q[s].x,i);
if(s>t||calc(q[t].x,n)<calc(i,n)){
while(s<=t&&calc(q[t].x,q[t].l)<calc(i,q[t].l))t--;
if(s<=t){j=find(q[t],i);q[t].r=j-1;q[++t]=node(i,j,n);}
else q[++t]=node(i,i,n);
}
}
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",a+i);
solve(1);
for(int i=1;i<=(n>>1);i++)swap(a[i],a[n-i+1]);
solve(0);
for(int i=1;i<=n;i++)printf("%d\n",max(0,(int)ceil(max(f[1][i],f[0][n-i+1]))));
return 0;
}