Submission #692573

#TimeUsernameProblemLanguageResultExecution timeMemory
692573owoovoGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
30 ms6960 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll ori[200010],pre[200010]={},pb[200010]={}; int main(){ cin.tie(0); ios::sync_with_stdio(0); ll n; cin>>n; for(int i=1;i<=n;i++){ cin>>ori[i]; } for(int i=2;i<=n;i++){ pre[i]=pre[i-1]; if(ori[i]<=ori[i-1]){ pre[i]+=ori[i-1]-ori[i]+1; } } for(int i=n;i>=1;i--){ pb[i]=pb[i+1]; if(ori[i]<=ori[i+1]){ pb[i]+=ori[i+1]-ori[i]+1; } } ll ans=100000000000000000; for(int i=1;i<=n;i++){ ans=min(ans,max(pre[i],pb[i])); } cout<<ans<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...