Submission #689714

#TimeUsernameProblemLanguageResultExecution timeMemory
689714prairie2022Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
90 ms5372 KiB
#include <bits/stdc++.h> #define int long long #define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0); #define sp <<' '<< using namespace std; signed main(){ int n, tmp, ans; cin >> n; vector<int> d(n); vector<int> a(n, 0); cin >> tmp; for(int i=1; i<n; i++){ cin >> d[i]; swap(d[i], tmp); d[i] = tmp-d[i]; } for(int i=1; i<n; i++){ if(d[i]>0) a[i] = a[i-1]; else a[i] = a[i-1]+1-d[i]; } ans = a[n-1]; tmp = 0; for(int i=n-1; i>0; i--){ if(d[i]>=0) tmp += 1+d[i]; ans = min(ans, max(a[i-1], tmp)); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...