제출 #1086928

#제출 시각아이디문제언어결과실행 시간메모리
1086928codexistent선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
// Key to solution lies in the fact that you cannot have more than 1 full-circle trip. // PROOF: Assume you have 2 full-circle trips. Then you travel 2L time and deliver >= 2K souvenirs. // But we can easily just deliver the first k souvenirs(from clockwise direction) in 2 * x time going // clockwise and deliver the first k souvenirs(from counter-clockwise direction) in at most 2 * (l - x) // time going counter-clockwise, which is just as good if not better. #include "boxes.h" using namespace std; #define ll long long #define MAXN 10000005 #define FOR(i, a, b) for(ll i = a; i <= b; i++) #define RFOR(i, a, b) for(ll i = a; i >= b; i--) ll dp_cw[MAXN], dp_ccw[MAXN], r = __LONG_LONG_MAX__; long long delivery(int N, int K, int L, int p[]) { dp_cw[0] = dp_ccw[N + 1] = 0; FOR(i, 1, N) dp_cw[i] = dp_cw[max(0, i - K)] + 2 * p[i - 1]; RFOR(i, N, 1) dp_ccw[i] = dp_ccw[min(N + 1, i + K)] + 2 * (N + 1 - p[i - 1]); FOR(i, 0, N) r = min(r, dp_cw[i] + dp_ccw[i + 1]); if(N >= K) FOR(i, 0, N) r = min(r, dp_cw[i] + dp_ccw[i + k + 1]); return r; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:17:35: error: 'max' was not declared in this scope
   17 |     FOR(i, 1, N) dp_cw[i] = dp_cw[max(0, i - K)] + 2 * p[i - 1];
      |                                   ^~~
boxes.cpp:18:38: error: 'min' was not declared in this scope
   18 |     RFOR(i, N, 1) dp_ccw[i] = dp_ccw[min(N + 1, i + K)] + 2 * (N + 1 - p[i - 1]);
      |                                      ^~~
boxes.cpp:20:22: error: 'min' was not declared in this scope
   20 |     FOR(i, 0, N) r = min(r, dp_cw[i] + dp_ccw[i + 1]);
      |                      ^~~
boxes.cpp:21:62: error: 'k' was not declared in this scope
   21 |     if(N >= K) FOR(i, 0, N) r = min(r, dp_cw[i] + dp_ccw[i + k + 1]);
      |                                                              ^
boxes.cpp:21:33: error: 'min' was not declared in this scope
   21 |     if(N >= K) FOR(i, 0, N) r = min(r, dp_cw[i] + dp_ccw[i + k + 1]);
      |                                 ^~~
boxes.cpp:15:38: warning: unused parameter 'L' [-Wunused-parameter]
   15 | long long delivery(int N, int K, int L, int p[]) {
      |                                  ~~~~^