# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1055141 | 2024-08-12T14:52:48 Z | manhlinh1501 | Growing Vegetable is Fun 3 (JOI19_ho_t3) | C++17 | 1 ms | 4444 KB |
#include <bits/stdc++.h> using namespace std; using i64 = long long; const i64 oo64 = 1e18; using pll = pair<i64, i64>; const int MAXN = 2e5 + 5; int N; i64 a[MAXN]; i64 b[MAXN]; pll prefix[MAXN]; bool is_dec[MAXN]; void PREFIX(i64 a[]) { i64 c = 0; for(int i = 1; i <= N; i++) { prefix[i].second = prefix[i - 1].second; a[i] += c; if(a[i] <= prefix[i - 1].first) { i64 x = (prefix[i - 1].first + 1) - a[i]; c += x; prefix[i].second += x; a[i] = prefix[i - 1].first + 1; } prefix[i].first = max(prefix[i - 1].first + 1, a[i]); } } signed main() { #define TASK "code" if (fopen(TASK ".inp", "r")) { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; for(int i = 1; i <= N; i++) cin >> a[i]; for(int i = 1; i <= N; i++) b[i] = a[i]; PREFIX(b); for(int i = N; i >= 1; i--) { if(a[i] > a[i + 1]) is_dec[i] = true; else break; } i64 ans = oo64; for(int i = 0; i <= N; i++) { if(is_dec[i]) ans = min(ans, prefix[i].second); } cout << ans; return (0 ^ 0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |