이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
long long ret = 0;
priority_queue<pair<int, int>> pq;
for (int i = 0; i < n; ++i) {
for (int j = m - 1; j >= m - k; --j) {
ret += x[i][j];
}
pq.emplace(-x[i][0] - x[i][m - k], i);
}
int cnt = 0;
vector<int> t(n);
while (cnt < n * k / 2) {
auto [val, ind] = pq.top();
pq.pop();
cnt++;
ret += val;
t[ind]++;
if (t[ind] < k) {
pq.emplace(-x[ind][t[ind]] - x[ind][m - k + t[ind]], ind);
}
}
while (!pq.empty()) pq.pop();
vector<int> c(n), c2(n);
for (int i = 0; i < n; ++i) {
c2[i] = m - k + t[i];
}
vector<vector<int>> answer(n, vector<int> (m, -1));
for (int round = 0; round < k; ++round) {
vector<int> ord(n);
iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&](int i, int j) {
return t[i] - c[i] > t[j] - c[j];
});
for (int j = 0, taken = 0; j < (int) ord.size(); ++j) {
if (taken < n / 2) {
answer[ord[j]][c[ord[j]]] = round;
c[ord[j]]++;
taken++;
} else {
answer[ord[j]][c2[ord[j]]] = round;
c2[ord[j]]++;
}
}
}
allocate_tickets(answer);
return ret;
}
# | 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... |