| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1358734 | putuputu | Growing Vegetables is Fun 4 (JOI21_ho_t1) | C++20 | 41 ms | 5036 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n;
cin >> n;
int a[n];
for(int i=0; i<n; i++){
cin >> a[i];
}
vector<int> l(n+2, 0), r(n+2, 0);
for(int i=1; i<n; i++){
int nd=max(0LL, a[i-1]-a[i]+1);
l[i]=l[i-1]+nd;
}
for(int i=n-2; i>=0; i--){
int nd=max(0LL, a[i+1]-a[i]+1);
r[i]=r[i+1]+nd;
}
int ans=1e18;
for(int i=0; i<n; i++){
ans=min(ans, max(r[i], l[i]));
}
cout << ans;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
