| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 830417 | RaresFelix | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++17 | 70 ms | 6984 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MN = 200071;
using ll = long long;
ll n, A[MN], St[MN], Dr[MN];
int main() {
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> A[i];
}
for(int i = n; i >= 1; --i) A[i] -= A[i - 1];
for(int i = 1; i < n; ++i) A[i] = A[i + 1];
--n;
ll s = 0;
for(int i = 1; i <= n; ++i) {
s += max(1 - A[i], 0ll);
St[i] = s;
}
s = 0;
for(int i = n; i >= 1; --i) {
s += max(A[i] + 1, 0ll);
Dr[i] = s;
}
ll re = min(St[n], Dr[1]);
for(int i = 1; i <= n; ++i) {
re = min(re, max(St[i], Dr[i + 1]));
}
cout << re << "\n";
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
