This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200050;
int n,a[MAXN],frnt[MAXN],bck[MAXN],curr,cb=INT_MAX;
int main(){
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i];
curr=a[1];
for (int i=2;i<=n;i++){
curr=max(curr+1,a[i]);
frnt[i]=max(frnt[i-1],curr-a[i]);
}
curr=a[n];
for (int i=n-1;i>=1;i--){
curr=max(curr+1,a[i]);
bck[i]=max(bck[i+1],curr-a[i]);
}
for (int i=1;i<=n;i++) cb=min(cb,max(frnt[i],bck[i]));
cout<<cb<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |