Submission #1134949

#TimeUsernameProblemLanguageResultExecution timeMemory
1134949MunkhturErdenebatGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
40 / 100
46 ms4936 KiB
#include<bits/stdc++.h> #include<string.h> #include <algorithm> #include <stdlib.h> #define ll long long using namespace std; ll k[300006],a,b,c,d,e,f,m[300006],i,j,n,h,g,l,r,ka,p,q[200005],t[200005]; map<ll,ll> maa,mii,mee; vector<ll> vas[25],vis,vii; int main(){ cin>>a; for(i=0 ; i<a ; i++){ cin>>k[i]; } h=1; for(i=1 ; i<a ; i++){ if(k[i]<=k[i-1]){ t[i]=k[i-1]-k[i]+1; } } g=0; h=1; for(i=a-2 ; i>=0 ; i--){ if(k[i+1]>=k[i]){ m[i]=k[i+1]-k[i]+1; } g+=m[i]; } h=1000000000000; l=0; for(i=0 ; i<a ; i++){ if(max(l+t[i],g)<h){ r=i; h=max(l+t[i],g); } g-=m[i]; l+=t[i]; } g=0; cout<<h<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...