제출 #921382

#제출 시각아이디문제언어결과실행 시간메모리
921382TAhmed33Growing Vegetables is Fun 4 (JOI21_ho_t1)C++98
100 / 100
21 ms7248 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 2e5 + 25; ll a[MAXN], n, pref[MAXN], suff[MAXN]; int main () { ios::sync_with_stdio(0); cin.tie(0); cin >> n; ll x; for (int i = 1; i <= n; i++) { ll y; cin >> y; a[i] = y - x; x = y; } ///for (int i = 2; i <= n; i++) cout << a[i] << " "; //cout << '\n'; for (int i = 2; i <= n; i++) { pref[i] = max(0ll, 1 - a[i]) + pref[i - 1]; } for (int i = n; i >= 2; i--) { suff[i] = max(0ll, a[i] + 1) + suff[i + 1]; } ll mn = suff[2]; for (int i = 2; i <= n; i++) { mn = min(mn, max(pref[i], suff[i + 1])); } cout << mn << '\n'; }

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

Main.cpp: In function 'int main()':
Main.cpp:11:12: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   11 |   a[i] = y - x; x = y;
      |          ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...