제출 #870669

#제출 시각아이디문제언어결과실행 시간메모리
870669Marco_EscandonGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++11
100 / 100
61 ms5420 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; cin>>n; ll cad[n]; ll ac[n]; ll ma=0; for(int i=0; i<n; i++) { cin>>cad[i]; ac[i]=max(ma-cad[i],0LL); ma=cad[i]+1; if(i>0) ac[i]+=ac[i-1]; } ll bs=1e17+7; ll sol=0; ma=0; for(int i=n-1; i>=0; i--) { sol+=max(ma-cad[i],0LL); ma=cad[i]+1; bs=min(bs,max(sol,ac[i])); } cout<<bs; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...