답안 #900499

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900499 2024-01-08T11:26:23 Z nguyentunglam 카니발 티켓 (IOI20_tickets) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;

long long find_maximum (int k, vector<vector<int> > x) {
  int n = x.size();
  int m = x[0].size();
  vector<vector<int> > answer;
  allocate_tickets(answer);
  return 0;
  vector<int> l(n + 2), r(n + 2);
  long long ans = 0;
  priority_queue<pair<long long, int> > q;
  for(int i = 0; i < n; i++) {
    l[i] = k - 1; r[i] = m - 1;
    for(int j = 0; j < k; j++) ans -= x[i][j];
    q.push({x[i][r[i]] + x[i][l[i]], i});
  }

  for(int loop = 1; loop <= n / 2 * k; loop++) {
    assert(q.size() >= 1);
    int cost, i; tie(cost, i) = q.top(); q.pop();
    ans += cost;
    l[i]--; r[i]--;
    if (l[i] >= 0) q.push({x[i][r[i]] + x[i][l[i]], i});
  }

  for(int i = 0; i < n; i++) r[i]++;

  int mn = 1e9, mx = -1e9;

  for(int i = 0; i < n; i++) {
    if (l[i] >= 0) mx = max(mx, x[i][l[i]]);
    if (r[i] < m) mn = min(mn, x[i][r[i]]);
  }

  assert(mx <= mn);

  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) answer[i][j] = -1;

  for(int round = 0; round < k; round++) {
    for(int i = 0, cnt1 = 0, cnt2 = 0; i < n; i++) {
      if (cnt1 < n / 2 && l[i] >= 0) {
        answer[i][l[i]] = round;
        l[i]--;
      }
      else if (cnt2 < n / 2 && r[i] < m) {
        answer[i][r[i]] = round;
        r[i]++;
      }
    }
  }
//  allocate_tickets
  return ans;
}

#ifdef ngu
int main() {

  freopen ("task.inp", "r", stdin);
  freopen ("task.out", "w", stdout);

  int n, m, k; cin >> n >> m >> k;

  vector<vector<int> > x(n, vector<int> (m));

  for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin >> x[i][j];

  cout << find_maximum(k, x);
}
#endif // ngu

Compilation message

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:12:3: error: 'allocate_tickets' was not declared in this scope
   12 |   allocate_tickets(answer);
      |   ^~~~~~~~~~~~~~~~