이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
ll ans = 0;
priority_queue<array<int, 2>> pq;
vector<int> c(n, 0);
for(int i=0;i<n;i++) {
for(int j=0;j<k;j++) ans -= x[i][j];
pq.push({x[i][m-1]+x[i][k-1], i});
}
for(int i=0;i<n*k/2;i++) {
auto [C, u] = pq.top(); pq.pop();
ans += C;
if(++c[u] == k) continue;
pq.push({x[u][m-1-c[u]]+x[u][k-1-c[u], u]});
}
while(!pq.empty()) pq.pop();
vector<int> L(n, 0), R(n, 0);
for(int i=0;i<n;i++) R[i] = m-c[i];
for(int i=0;i<n;i++) c[i] = k-c[i], pq.push({c[i], i});
vector<vector<int>> re(n, vector<int>(m, -1));
for(int i=0;i<k;i++) {
set<int> s;
for(int j=0;j<n/2;j++) s.insert(pq.top()[1]), pq.pop();
for(int j=0;j<n;j++) {
if(s.count(j)) re[j][L[j]++] = i;
else re[j][R[j]++] = i;
}
for(auto x : s) pq.push({--c[x], x});
}
allocate_tickets(re);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:22:41: warning: value computed is not used [-Wunused-value]
22 | pq.push({x[u][m-1-c[u]]+x[u][k-1-c[u], u]});
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |