제출 #346281

#제출 시각아이디문제언어결과실행 시간메모리
346281dennisstarCarnival Tickets (IOI20_tickets)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; using ll = long long; ll find_maximum(int K, vector<vector<int>> X) { int N = X.size(), M=X[0].size(); vector<int> T(N), l(N), r(N); priority_queue<pair<int, int>> pq; for (int i=0; i<N; i++) pq.emplace(X[i][M-1]+X[i][K-1], i); for (int i=0; i<K*N/2; i++) { int j=pq.top().second; pq.pop(); T[j]++; if (T[j]<K) pq.emplace(X[j][M-1-T[j]]+X[j][K-1-T[j]], i); } vector<vector<int>> A; while (pq.size()) pq.pop(); for (int i=0; i<N; i++) A.emplace_back(vector<int>(M, -1)), pq.emplace(T[i], i); int mx=0, mn=(1e9); for (int i=0; i<N; i++) { if (T[i]<K) mx=max(mx, X[i][K-T[i]-1]); if (T[i]) mn=min(mn, X[i][M-T[i]]); } assert(mx<=mn); ll R=0; for (int i=0; i<K; i++) { vector<int> chk(N); for (int j=0; j<N/2; j++) chk[pq.top().second]=1, pq.pop(); for (int j=0; j<N; j++) { if (chk[j]) { l[j]++; A[j][M-l[j]]=i; R+=X[j][M-l[j]]; pq.emplace(T[j]-l[j], j); k++; } else A[j][r[j]]=i, R-=X[j][r[j]], r[j]++; } } allocate_tickets(A); return R; }

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

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:44:5: error: 'k' was not declared in this scope
   44 |     k++;
      |     ^