이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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();
res += 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 = n / 2; j < n; j++) {
ans[ord[j]][pr[ord[j]]--] = i;
}
}
allocate_tickets(ans);
return res;
}
# | 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... |