제출 #856807

#제출 시각아이디문제언어결과실행 시간메모리
856807drome삶의 질 (IOI10_quality)C++14
컴파일 에러
0 ms0 KiB
#include "quality.h" #include <string.h> #include <iostream> #include <algorithm> typedef long long ll; int rectangle(int R, int C, int H, int W, int Q[3001][3001]) { ll lo = 1, hi = R * C; int leq[3001][3001]; int ps[3001][3001]; for (int _=0;_<100;_++) { ll mi = (lo + hi) / 2; memset(leq, 0, sizeof(leq)); for (int i=0;i<R;i++) for (int j=0;j<C;j++) { leq[i][j] = (Q[i][j] <= mi); ps[i][j] = leq[i][j]; if (i) ps[i][j] += ps[i-1][j]; if (j) ps[i][j] += ps[i][j-1]; if (i && j) ps[i][j] -= ps[i-1][j-1]; } // cout << "MI: " << mi << endl; // for (int i=0;i<R;i++) { // for (int j=0;j<C;j++) { // cout << leq[i][j] << " "; // } // cout << endl; // } // for (int i=0;i<R;i++) { // for (int j=0;j<C;j++) { // cout << ps[i][j] << " "; // } // cout << endl; // } ll maxsum = 0; for (int i=0;i+H<=R;i++) for (int j=0;j+W<=C;j++) { ll sum = ps[i+H-1][j+W-1]; if (i) sum -= ps[i-1][j+W-1]; if (j) sum -= ps[i+H-1][j-1]; if (i && j) sum += ps[i-1][j-1]; maxsum = max(maxsum, sum); } // cout << "maxsum: " << maxsum << endl; if (maxsum > (W * H) / 2) hi = mi; else lo = mi + 1; } return lo; }

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

quality.cpp: In function 'int rectangle(int, int, int, int, int (*)[3001])':
quality.cpp:47:13: error: 'max' was not declared in this scope; did you mean 'std::max'?
   47 |    maxsum = max(maxsum, sum);
      |             ^~~
      |             std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from quality.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~