Submission #774557

#TimeUsernameProblemLanguageResultExecution timeMemory
774557kirakaminski968Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms308 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int MAXN = 2e5+5; ll arr[MAXN],f[MAXN],g[MAXN]; ll INF = 1e18; int main() { int N; cin >> N; for(int i = 1;i<=N;++i) cin >> arr[i]; for(int i = 1;i<=N;++i){ f[i] = f[i-1]+max(arr[i+1]-arr[i]+1,0ll); } for(int i = N;i>=0;--i){ g[i] = g[i+1]+max(arr[i+1]-arr[i]+1,0ll); } ll ans = INF; for(int i = 1;i<=N;++i){ ans = min(max(f[i],g[i]),ans); } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...