제출 #1008436

#제출 시각아이디문제언어결과실행 시간메모리
1008436AtinaRGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
65 ms7252 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin>>n; long long niza[n]; for(long long i=0; i<n; i++) { cin>>niza[i]; } long long a[n],b[n]; a[0]=0,b[n-1]=0; for(long long i=1; i<n; i++) { a[i]=a[i-1]; if(niza[i]<=niza[i-1]) { a[i]+=niza[i-1]-niza[i]+1; } } for(long long i=n-2; i>=0; i--) { b[i]=b[i+1]; if(niza[i]<=niza[i+1]) { b[i]+=niza[i+1]-niza[i]+1; } } long long res=1e18; for(long long i=0; i<n; i++)res=min(res,max(a[i],b[i])); cout<<res<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...