| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 783264 | borisAngelov | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++17 | 22 ms | 6168 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 maxn = 200005;
int n;
int a[maxn];
long long preffix[maxn];
long long suffix[maxn];
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
}
for (int i = 2; i <= n; ++i)
{
preffix[i] = preffix[i - 1] + max(0, a[i - 1] - a[i] + 1);
}
for (int i = n - 1; i >= 1; --i)
{
suffix[i] = suffix[i + 1] + max(0, a[i + 1] - a[i] + 1);
}
long long ans = (1ll << 62);
for (int i = 1; i <= n; ++i)
{
ans = min(ans, max(preffix[i], suffix[i]));
}
cout << ans << endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
