Submission #761737

#TimeUsernameProblemLanguageResultExecution timeMemory
761737DavidAA007Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
86 ms10132 KiB
#include<bits/stdc++.h> #define mod 1000000007 #define inf 0x3f3f3f3f #define bit(x,i)(((x)>>(i))&1) #define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); using namespace std; ifstream fin("partit.in"); ofstream fout("partit.out"); const long long int mare=1LL*1000000000000000000; long long int T,n,m,ok,i,j,k,t; long long int c,aux,start,maxx,summax,minn; long long int contor,suma,poz,dim; long long int v[200005],st[200005],dr[200005],sumst[200005],sumdr[200005]; int main() { cin>>n; for(i=1;i<=n;i++) { cin>>v[i]; } st[1]=v[1]; for(i=2;i<=n;i++) { st[i]=v[i]+sumst[i-1]; sumst[i]=sumst[i-1]; if(st[i]<=st[i-1]) { sumst[i]+=(st[i-1]-st[i])+1; st[i]=st[i-1]+1; } } dr[n]=v[n]; for(i=n-1;i>=1;i--) { dr[i]=v[i]+sumdr[i+1]; sumdr[i]=sumdr[i+1]; if(dr[i]<=dr[i+1]) { sumdr[i]+=(dr[i+1]-dr[i])+1; dr[i]=dr[i+1]+1; } } contor=mare; for(i=1;i<=n;i++) { contor=min(contor,max(sumst[i],sumdr[i])); } cout<<contor; return 0; } /* 7 12 2 34 85 4 91 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...