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;
int main() {
int n;
cin>>n;
vector<int>vegetales(n);
for(int i=0;i<n;i++){
cin>>vegetales[i];
}
vector<int>a(n);
a[0]=0;
for(int i=1;i<n;i++){
a[i]=max(vegetales[i],a[i-1]+1+vegetales[i-1])-vegetales[i];
}
reverse(vegetales.begin(),vegetales.end());
vector<int>b(n);
b[0]=0;
for(int i=1;i<n;i++){
b[i]=max(vegetales[i],b[i-1]+1+vegetales[i-1])-vegetales[i];
}
int ans=-1;
for(int i=0;i<n;i++){
ans=max(ans,max(a[i],b[n-1-i]));
}
cout<<ans<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |