Submission #906674

#TimeUsernameProblemLanguageResultExecution timeMemory
906674imarnGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
27 ms5208 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<ll,ll> #define f first #define s second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n;cin>>n; ll a[n+1]; for(int i=1;i<=n;i++)cin>>a[i]; ll dpl[n+1];dpl[1]=0; for(int i=2;i<=n;i++)dpl[i]=dpl[i-1]+(a[i-1]-a[i]>=0?a[i-1]-a[i]+1:0); ll dpr[n+2]={0};dpr[n]=0; for(int i=n-1;i>=1;i--)dpr[i]=dpr[i+1]+(a[i+1]-a[i]>=0?a[i+1]-a[i]+1:0); ll ans=2e18; for(int i=1;i<=n;i++)ans=min(ans,max(dpl[i],dpr[i]));cout<<ans; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:19:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   19 |     for(int i=1;i<=n;i++)ans=min(ans,max(dpl[i],dpr[i]));cout<<ans;
      |     ^~~
Main.cpp:19:58: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   19 |     for(int i=1;i<=n;i++)ans=min(ans,max(dpl[i],dpr[i]));cout<<ans;
      |                                                          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...