제출 #315599

#제출 시각아이디문제언어결과실행 시간메모리
315599VEGAnn카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include "tickets.h" #include <bits/stdc++.h> #define PB push_back #define sz(x) ((int)x.size()) #define all(x) x.begin(),x.end() #define i2 array<int,2> using namespace std; typedef long long ll; const int N = 1600; const ll OO = 1e18; priority_queue<i2> pq; int ptr[N]; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> answer; for (int i = 0; i < n; i++) { std::vector<int> row(m); fill(all(row), -1); answer.push_back(row); } ll ans = 0; for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++) ans += x[i][m - k + j]; ptr[i] = 0; cand[i] = 0; pq.push({-x[i][m - k] - x[i][0], i}); } // add again to pq only if ptr < m for (int itr = (n / 2) * k; itr > 0; itr--){ i2 now = pq.top(); pq.pop(); ans += now[0]; int id = now[1]; ptr[id]++; if (ptr[id] < k){ pq.push({-x[id][m - k + ptr[id]] - x[id][ptr[id]], id}); } } // add last tickets for (int i = 0, g1 = 0; i < n; i++){ int now = 0; for (int j = 0; j < ptr[i]; j++){ answer[i][m - k + j] = g1; g1++; if (g1 == k) g1 = 0; } for (int j = ptr[i], now = g1; j < k; j++){ answer[i][m - k + j] = now; now++; if (now == k) now = 0; } } allocate_tickets(answer); return ans; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:35:9: error: 'cand' was not declared in this scope; did you mean 'rand'?
   35 |         cand[i] = 0;
      |         ^~~~
      |         rand
tickets.cpp:58:13: warning: unused variable 'now' [-Wunused-variable]
   58 |         int now = 0;
      |             ^~~