Submission #756761

#TimeUsernameProblemLanguageResultExecution timeMemory
756761Nika533Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
23 ms5076 KiB
#pragma GCC diagnostic warning "-std=c++11" #include <bits/stdc++.h> #define int long long #define pb push_back #define f first #define s second #define MOD 1000000007 #define flush fflush(stdout) #define all(x) (x).begin(),(x).end() using namespace std; int n,m,T,k; string s; void test_case() { cin>>n; int arr[n+2]; arr[0]=0; arr[n+1]=0; int pref[n+2]; pref[0]=0; pref[n+1]=0; int suf[n+2]; suf[0]=0; suf[n+1]=0; for (int i=1; i<=n; i++) { cin>>arr[i]; } for (int i=1; i<=n; i++) { if (arr[i]>arr[i-1]) { pref[i]=pref[i-1]; continue; } int val=arr[i-1]-arr[i]+1; pref[i]=pref[i-1]; pref[i]+=val; } for (int i=n; i>=1; i--) { if (arr[i]>arr[i+1]) { suf[i]=suf[i+1]; continue; } int val=arr[i+1]-arr[i]+1; suf[i]=suf[i+1]; suf[i]+=val; } int ans=1e18; for (int i=1; i<=n; i++) { //cout<<i<<" "<<pref[i]<<" "<<suf[i]<<endl; ans=min(ans,max(pref[i],suf[i])); } cout<<ans<<endl; } main () { ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0); T=1; while (T--) { test_case(); } }

Compilation message (stderr)

Main.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
Main.cpp:53:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   53 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...