Submission #698822

#TimeUsernameProblemLanguageResultExecution timeMemory
698822US3RN4M3Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int mx = 200005; int A[mx]; ll pref_cost[mx]; ll suff_cost[mx]; int n; main() { cin >> n; for(int i = 1; i <= n; i++) cin >> A[i]; for(int i = 1; i <= n; i++) pref_cost[i] = pref_cost[i - 1] + max(0, 1 + A[i - 1] - A[i]); for(int i = n; i >= 1; i--) suff_cost[i] = suff_cost[i + 1] + max(0, 1 + A[i + 1] - A[i]); ll ans = 1e18; for(int i = 0; i <= n; i++) { ans = min(ans, max(pref_cost[i], suff_cost[i + 1])); } cout << ans << endl; }

Compilation message (stderr)

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