Submission #379507

#TimeUsernameProblemLanguageResultExecution timeMemory
379507penguin133Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
93 ms5740 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int A[200005], P[200005], S[200005],ans = LLONG_MAX; main(){ int n; cin >> n; for(int i=1;i<=n;i++){ cin >> A[i]; if(i > 1){ P[i] = P[i-1] + max(0ll, A[i-1]- A[i] + 1); } } for(int i=n-1;i>=1;i--)S[i] = S[i+1] + max(0ll, A[i+1] - A[i] + 1); for(int i=1;i<=n;i++)ans = min(ans, max(P[i], S[i])); cout << ans; }

Compilation message (stderr)

Main.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...