제출 #503329

#제출 시각아이디문제언어결과실행 시간메모리
503329WongChun1234Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
0 / 100
1 ms332 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...