제출 #979555

#제출 시각아이디문제언어결과실행 시간메모리
979555kilkuwu선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include "boxes.h" #ifdef LOCAL #include "template/debug.hpp" #else #define dbg(...) ; #define timer(...) ; #endif long long delivery(int N, int K, int L, int p[]) { int split = std::upper_bound(p, p + N, L / 2) - p; int left = split; int right = split; long long ans = 0; while (left >= K) { ans += p[left - 1] * 2; left -= K; } while (N - right >= K) { ans += (L - p[right]) * 2; right += K; } // now what can we do ? // we can go in either direction if (right == N && left == 0) return ans; if (right == N || left == 0) { if (right == N) { return ans + p[left - 1] * 2; } else { return ans + (L - p[right]) * 2; } } // both of em are non negative long long naive = ans + p[left - 1] * 2 + (L - p[right]) * 2; // that's the naieve solution int tot = left + N - right; long long round = ans + L; if (tot > K) { int left_remain = tot - K; int right_remain = tot - K; round += std::min(p[left_remain - 1], L - p[N - right_remain]) * 2; } ans += std::min(naive, round); return ans; } #ifdef LOCAL int main() { int N, K, L, i; std::cin >> N >> K >> L; int *p = (int*)malloc(sizeof(int) * (unsigned int)N); for (i = 0; i < N; i++) { std::cin >> p[i]; } std::cout << delivery(N, K, L, p) << "\n"; return 0; } #endif

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:11:20: error: 'upper_bound' is not a member of 'std'
   11 |   int split = std::upper_bound(p, p + N, L / 2) - p;
      |                    ^~~~~~~~~~~
boxes.cpp:51:19: error: 'min' is not a member of 'std'
   51 |     round += std::min(p[left_remain - 1], L - p[N - right_remain]) * 2;
      |                   ^~~
boxes.cpp:54:15: error: 'min' is not a member of 'std'
   54 |   ans += std::min(naive, round);
      |               ^~~