제출 #698823

#제출 시각아이디문제언어결과실행 시간메모리
698823US3RN4M3Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
87 ms6200 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int mx = 200005; int A[mx]; ll pref_cost[mx]; ll suff_cost[mx]; int n; main() { cin >> n; for(int i = 1; i <= n; i++) cin >> A[i]; for(int i = 1; i <= n + 1; i++) pref_cost[i] = pref_cost[i - 1] + max(0, 1 + A[i - 1] - A[i]); for(int i = n; i >= 0; i--) suff_cost[i] = suff_cost[i + 1] + max(0, 1 + A[i + 1] - A[i]); ll ans = 1e18; for(int i = 0; i <= n; i++) { ans = min(ans, max(pref_cost[i], suff_cost[i])); } cout << ans << endl; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...