Submission #372620

#TimeUsernameProblemLanguageResultExecution timeMemory
372620blueGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
105 ms5100 KiB
#include <iostream> using namespace std; int main() { int N; cin >> N; long long A[N+1]; for(int i = 1; i <= N; i++) cin >> A[i]; long long res = 4'000'000'000'000'000'000; long long inc[N+1], dec[N+1]; inc[1] = 0; dec[N] = 0; for(int i = 2; i <= N; i++) inc[i] = inc[i-1] + max((A[i-1] + 1) - A[i], 0LL); for(int i = N-1; i >= 1; i--) dec[i] = dec[i+1] + max((A[i+1] + 1) - A[i], 0LL); for(int i = 1; i <= N; i++) res = min(res, max(inc[i], dec[i])); cout << res << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...