제출 #704071

#제출 시각아이디문제언어결과실행 시간메모리
704071StickfishGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
0 / 100
2 ms332 KiB
#include <iostream> using namespace std; const int MAXN = 2e5 + 123; int a[MAXN]; signed main() { int n; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = n - 1; i > 0; --i) a[i] -= a[i - 1]; int ans = 0; int rval = 0; for (int i = 1; i < n; ++i) rval += max(0, a[i] + 1); int lval = 0; ans = rval; for (int i = 1; i < n; ++i) { rval -= max(0, a[i] + 1); lval += max(0, -a[i] + 1); ans = min(ans, max(rval, lval)); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...