제출 #539049

#제출 시각아이디문제언어결과실행 시간메모리
539049groshiGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
24 ms3916 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-1]=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...