Submission #585904

#TimeUsernameProblemLanguageResultExecution timeMemory
585904krit3379Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define N 200005 long long a[N],dp1[N],dp2[N],ma,ans=1e18; int main(){ int n,i; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%lld",&a[i]); ma=0; for(i=1;i<=n;i++){ ma=max(ma,a[i]-i); dp1[i]=ma-a[i]+i; dp1[i]=max(dp1[i],dp1[i-1]); } ma=0; for(i=n;i;i--){ ma=max(ma,a[i]+i); dp2[i]=ma-a[i]-i; dp2[i]=max(dp2[i],dp2[i+1]); } for(i=1;i<=n;i++)ans=min(ans,max(dp1[i],dp2[i])); printf("%lld",ans); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
Main.cpp:10:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for(i=1;i<=n;i++)scanf("%lld",&a[i]);
      |                      ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...