# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
379507 | penguin133 | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++14 | 93 ms | 5740 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;
#define int long long
int A[200005], P[200005], S[200005],ans = LLONG_MAX;
main(){
int n;
cin >> n;
for(int i=1;i<=n;i++){
cin >> A[i];
if(i > 1){
P[i] = P[i-1] + max(0ll, A[i-1]- A[i] + 1);
}
}
for(int i=n-1;i>=1;i--)S[i] = S[i+1] + max(0ll, A[i+1] - A[i] + 1);
for(int i=1;i<=n;i++)ans = min(ans, max(P[i], S[i]));
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |