Submission #908852

#TimeUsernameProblemLanguageResultExecution timeMemory
908852vjudge1Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms348 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...