Submission #539047

#TimeUsernameProblemLanguageResultExecution timeMemory
539047groshiGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms212 KiB
#include<iostream> using namespace std; int roz[1000000]; int t[1000000]; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n; cin>>n; for(int i=1;i<=n;i++) { cin>>t[i]; if(i>1) roz[i]=t[i]-t[i-1]; } long long suma1=0; long long suma2=0; for(int i=1;i<n;i++) if(roz[i]<=0) suma1-=roz[i]-1; long long wynik=suma1; for(int i=n-1;i>=1;i--) { if(roz[i]<=0) suma1+=roz[i]-1; else suma2+=roz[i]+1; if(roz[i]==0) suma2++; wynik=min(wynik,max(suma1,suma2)); } cout<<wynik; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...