제출 #467441

#제출 시각아이디문제언어결과실행 시간메모리
467441SirCovidThe19th로봇 (IOI13_robots)C++17
컴파일 에러
0 ms0 KiB
#include "robots.h" using namespace std; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){ pair<int, int> toys[T]; for (int i = 0; i < T; i++) toys[i] = {W[i], S[i]}; sort(toys, toys + T); auto check = [&](int mid){ priority_queue<int> pq; int pt = 0; for (int i = 0; i < A; i++){ for (; pt < T and toys[pt].first < X[i]; pt++) pq.push(toys[pt].second); for (int j = 0; j < mid and !pq.empty(); j++) pq.pop(); } for (; pt < T; pt++) pq.push(toys[pt].second); for (int i = B - 1; i >= 0; i--){ for (int j = 0; j < mid and !pq.empty() and pq.top() < Y[i]; j++) pq.pop(); } return pq.empty(); }; int low = 1, high = T + 1; while (low < high){ int mid = (low + high) / 2; check(mid) ? high = mid : low = mid + 1; } return (high == T + 1) ? -1 : high; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:5:5: error: 'pair' was not declared in this scope
    5 |     pair<int, int> toys[T];
      |     ^~~~
robots.cpp:2:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
    1 | #include "robots.h"
  +++ |+#include <utility>
    2 | using namespace std;
robots.cpp:5:10: error: expected primary-expression before 'int'
    5 |     pair<int, int> toys[T];
      |          ^~~
robots.cpp:6:33: error: 'toys' was not declared in this scope
    6 |     for (int i = 0; i < T; i++) toys[i] = {W[i], S[i]};
      |                                 ^~~~
robots.cpp:7:10: error: 'toys' was not declared in this scope
    7 |     sort(toys, toys + T);
      |          ^~~~
robots.cpp:7:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    7 |     sort(toys, toys + T);
      |     ^~~~
      |     short
robots.cpp: In lambda function:
robots.cpp:10:9: error: 'priority_queue' was not declared in this scope
   10 |         priority_queue<int> pq; int pt = 0;
      |         ^~~~~~~~~~~~~~
robots.cpp:2:1: note: 'std::priority_queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    1 | #include "robots.h"
  +++ |+#include <queue>
    2 | using namespace std;
robots.cpp:10:24: error: expected primary-expression before 'int'
   10 |         priority_queue<int> pq; int pt = 0;
      |                        ^~~
robots.cpp:12:60: error: 'pq' was not declared in this scope; did you mean 'pt'?
   12 |             for (; pt < T and toys[pt].first < X[i]; pt++) pq.push(toys[pt].second);
      |                                                            ^~
      |                                                            pt
robots.cpp:13:42: error: 'pq' was not declared in this scope; did you mean 'pt'?
   13 |             for (int j = 0; j < mid and !pq.empty(); j++) pq.pop();
      |                                          ^~
      |                                          pt
robots.cpp:15:30: error: 'pq' was not declared in this scope; did you mean 'pt'?
   15 |         for (; pt < T; pt++) pq.push(toys[pt].second);
      |                              ^~
      |                              pt
robots.cpp:17:42: error: 'pq' was not declared in this scope; did you mean 'pt'?
   17 |             for (int j = 0; j < mid and !pq.empty() and pq.top() < Y[i]; j++) pq.pop();
      |                                          ^~
      |                                          pt
robots.cpp:19:16: error: 'pq' was not declared in this scope; did you mean 'pt'?
   19 |         return pq.empty();
      |                ^~
      |                pt