제출 #1274770

#제출 시각아이디문제언어결과실행 시간메모리
1274770MisterReaperGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
100 / 100
32 ms4340 KiB
// File vegetables4.cpp created on 30.09.2025 at 19:13:23 #include <bits/stdc++.h> using i64 = long long; #ifdef DEBUG #include "/home/ahmetalp/Desktop/Workplace/debug.h" #else #define debug(...) void(23) #endif int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N; std::cin >> N; std::vector<int> A(N); for (int i = 0; i < N; ++i) { std::cin >> A[i]; } std::vector<i64> pre(N), suf(N); for (int i = 0; i + 1 < N; ++i) { pre[i + 1] = pre[i] + std::max(0, 1 + A[i] - A[i + 1]); } for (int i = N - 1; i > 0; --i) { suf[i - 1] = suf[i] + std::max(0, 1 + A[i] - A[i - 1]); } i64 ans = i64(1E18); for (int i = 0; i < N; ++i) { ans = std::min(ans, std::max(pre[i], suf[i])); } std::cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...