제출 #54207

#제출 시각아이디문제언어결과실행 시간메모리
54207WLZ선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include "boxes.h"
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#ifdef DEBUG
#define debug(x) cout << #x << ' ' << x << '\n'
#else
#define debug(x)
#endif

long long delivery(int N, int K, int L, vector<int> p) {
  int idx = 0;
  int left = N;
  long long ans = 0ll;
  while (left > 0) {
    vector<int> cur;
    for (int i = idx; i < min(idx + K, N); i++) {
      cur.push_back(p[i]);
      left--;
    }
    idx += K;
    long long takeLeft = 0ll;
    long long takeRight = 0ll;

    {
      int pos = 0;
      for (auto& x : cur) {
        takeLeft += (long long) (x - pos);
        debug(takeLeft);
        pos = x;
      }
      takeLeft += (long long) (min(pos, L - pos));
    }

    {
      int pos = L;
      reverse(cur.begin(), cur.end());
      for (auto& x : cur) {
        takeRight += (long long) (pos - x);
        debug(takeRight);
        pos = x;
      }
      takeRight += (long long) (min(pos, L - pos));
    }
    ans += min(takeLeft, takeRight);
    debug(ans);
  }
  return ans;
}
/*
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, l, p[1005];
  cin >> n >> k >> l;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  cout << delivery(n, k, l, p) << endl;
  return 0;
}
*/

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

/tmp/cc7KbY05.o: In function `main':
grader.c:(.text.startup+0x22f): undefined reference to `delivery(int, int, int, int*)'
collect2: error: ld returned 1 exit status