제출 #1154721

#제출 시각아이디문제언어결과실행 시간메모리
1154721minggaGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() #define ln '\n' const int N = 1e5 + 7; const int inf = 2e18; int n, a[N], rig[N], d[N]; signed main() { cin.tie(0) -> sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; } int ans = inf; for(int i = 1; i <= n; i++) { d[i] = a[i] - a[i - 1]; // cerr << d[i] << ' '; } // cerr << ln; for(int i = n; i > 0; i--) { rig[i] = rig[i + 1]; if(d[i] >= 0) rig[i] += d[i] + 1; } int cur = 0; for(int i = 1; i <= n; i++) { if(d[i] <= 0) cur += 1 - d[i]; // cerr << i << ' ' << cur << ' ' << rig[i + 1] << ln; ans = min(ans, max(cur, rig[i + 1])); } cout << ans << ln; }

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

Main.cpp:12:17: warning: overflow in conversion from 'double' to 'int' changes value from '2.0e+18' to '2147483647' [-Woverflow]
   12 | const int inf = 2e18;
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...