제출 #758937

#제출 시각아이디문제언어결과실행 시간메모리
758937ridicheGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> using namespace std; int a[200005]; int cr[200005], cn[200005], ce[200005]; int dr[200005], dn[200005], de[200005]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } cn[0] = a[0]; for (int i = 1; i < n; i++) { if (a[i] > cn[i - 1]) { cr[i] = 0; cn[i] = a[i]; ce[i] = 0; } else { cn[i] = cn[i - 1] + 1; ce[i] = cn[i] - a[i]; cr[i] = cr[i - 1] + max(0, ce[i] - ce[i - 1]); } } dn[n - 1] = a[n - 1]; for (int i = n-2; i >= 0; i--) { if (a[i] > dn[i + 1]) { dr[i] = 0; dn[i] = a[i]; de[i] = 0; } else { dn[i] = dn[i + 1] + 1; de[i] = dn[i] + a[i]; dr[i] = dr[i + 1] + max(0, de[i] - de[i + 1]); } } int r = INT_MAX; for (int i = 0; i < n; i++) { r = min(r, cr[i] + dr[i] - min(ce[i], de[i])); } cout << r; }

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

Main.cpp: In function 'int main()':
Main.cpp:49:10: error: 'INT_MAX' was not declared in this scope
   49 |  int r = INT_MAX;
      |          ^~~~~~~
Main.cpp:2:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    1 | #include <iostream>
  +++ |+#include <climits>
    2 |