# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548193 | Pherokung | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++14 | 44 ms | 6948 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;
long long n,a[200005],v0[200005],v1[200005],ans=1e18;
int main(){
scanf("%lld",&n);
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
for(int i=1;i<=n+1;i++) v0[i] = v0[i-1] + max((long long)0,a[i-1]-a[i]+1);
for(int i=n;i>=0;i--) v1[i] = v1[i+1] + max((long long)0,a[i+1]-a[i]+1);
for(int i=1;i<=n;i++) ans = min(ans,max(v0[i],v1[i]));
printf("%lld",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |