Submission #1057121

#TimeUsernameProblemLanguageResultExecution timeMemory
1057121aufanCarnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long find_maximum(int k, vector<vector<int>> a) { int n = (int)a.size(), m = (int)a[0].size(); long long res = 0; vector<vector<int>> bad(n, vector<int>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { res -= a[i][j]; } } priority_queue<array<int, 3>> pq; for (int i = 0; i < n; i++) { pq.push({a[i][m - 1] + a[i][k - 1], i, 0}); } vector<int> cnt(n, k); for (int i = 0; i < n * k / 2; i++) { auto [x, j, d] = pq.top(); pq.pop(); ans += x; cnt[j] -= 1; if (d + 1 < k - 1) pq.push({a[j][m - 1 - (d + 1)] + a[j][k - 1 - (d + 1)], j, d + 1}); } vector<int> pl(n, 0), pr(n, m - 1); vector<vector<int>> ans(n, vector<int>(m, -1)); for (int i = 0; i < k; i++) { vector<int> ord(n); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](int x, int y) { return cnt[x] > cnt[y]; }); for (int j = 0; j < n / 2; j++) { ans[ord[j]][pl[ord[j]]++] = i; cnt[ord[j]] -= 1; } for (int j = 0; j < n / 2; j++) { ans[ord[j]][pr[ord[j]]--] = i; } } allocate_tickets(ans); return res; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:26:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   26 |   ans += x;
      |   ^~~
      |   abs