| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1358763 | nini_gvenetadze | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++20 | 39 ms | 5048 KiB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n;
cin>>n;
vector<ll> a(n);
for(int i=0; i<n; i++)
{
cin>>a[i];
}
vector<ll> pre(n, 0), suf(n, 0);
for(int i=1; i<n; i++)
{
ll p=a[i-1]-a[i]+1;
if(p<0) p=0;
pre[i]=pre[i-1]+p;
}
for(int i=n-2; i>=0; i--)
{
ll p=a[i+1]-a[i]+1;
if(p<0) p=0;
suf[i]=suf[i+1]+p;
}
ll ans=1e18;
for(int k=0; k<n; k++)
{
ll c=max(pre[k], suf[k]);
ans=min(ans, c);
}
cout<<ans<<endl;
return 0;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
