Submission #916325

#TimeUsernameProblemLanguageResultExecution timeMemory
916325ace5Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
69 ms4712 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int r[n-1]; int64_t pr[n]; int o; cin >> o; pr[0] = 0; for(int i = 1;i < n;++i) { int x; cin >> x; r[i-1] = x-o; pr[i] = pr[i-1] + max(0,1-r[i-1]); o = x; } int64_t ans = 1e18; int64_t sf = 0; for(int i = n-1;i >= 0;--i) { ans = min(ans,max(pr[i],sf)); sf += (i == 0 ? 0 : max(0,r[i-1]+1)); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...