Submission #1311494

#TimeUsernameProblemLanguageResultExecution timeMemory
1311494madamadam3Growing Vegetables is Fun 4 (JOI21_ho_t1)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int signed main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; vector<int> a(n), r(n, 0); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n; i++) r[n-i-1] = max(0LL, (a[n-i] + 1) - (a[n-i-1])) + r[n-i]; int t = 4e18, f = 0; for (int i = 1; i < n; i++) f += max(0LL, (a[i-1] + 1) - a[i]), t = min(t, max(r[i], f)); cout << t << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...