이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size(), m = x[0].size();
long long S = 0;
vector<vector<int>> answer(n, vector<int>(m, -1));
vector<int> l(n, -1), r(n, m);
priority_queue<pair<ll, int>> pq;
for (int i = 0; i < n; i++) {
for (int j = 0; j < k; j++) {
S -= x[i][++l[i]];
pq.push({x[i][j] + x[i][m - k + j], i});
}
}
for (int iter = 0; iter < (n / 2) * k; iter++) {
int i = pq.top().second;
pq.pop();
S += x[i][--r[i]];
S += x[i][l[i]--];
}
for (int iter = 0; iter < k; iter++) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (r[i] == m) {
answer[i][l[i]--] = iter;
cnt++;
}
}
assert(cnt <= n / 2);
for (int i = 0; i < n; i++) {
if (r[i] == m) continue;
if (cnt < n / 2 && l[i] >= 0) {
answer[i][l[i]--] = iter;
cnt++;
} else {
answer[i][r[i]++] = iter;
}
}
}
allocate_tickets(answer);
return S;
}
# | 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... |