제출 #391596

#제출 시각아이디문제언어결과실행 시간메모리
391596l3nl3Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int mxsz = 2e5 + 10; const int inf = 1e9 + 7; int n, a[mxsz], p[mxsz], s[mxsz], mn=inf; signed main () { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; p[i] = p[i-1] + max(0ll, 1 - (a[i] - 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 = 2; i < n; i++) { mn = min(mn, max(p[i], s[i])); } cout << mn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...