Submission #1086930

#TimeUsernameProblemLanguageResultExecution timeMemory
1086930codexistentBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
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 MAXN 10000005 #define FOR(i, a, b) for(long long i = a; i <= b; i++) #define RFOR(i, a, b) for(long long i = a; i >= b; i--) long long 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((long long)0, (long long)i - K)] + 2 * p[i - 1]; RFOR(i, N, 1) dp_ccw[i] = dp_ccw[min(N + 1, i + K)] + 2 * (L + 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; }

Compilation message (stderr)

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