이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ar array
#define ll long long
#define all(x) x.begin(), x.end()
#include "tickets.h"
using namespace std;
const ll INF = 1e18;
long long find_maximum(int k, std::vector<std::vector<int>> a) {
int n = a.size();
int m = a[0].size();
ll ans2 = 0;
for (int i = 0; i < n; i++) for (int j = 0; j < k; j++) ans2 -= a[i][j];
vector<int> at(n, k - 1);
priority_queue<ar<ll, 2>> q;
for (int i = 0; i < n; i++) q.push({a[i][k-1] + a[i][m-1], i});
for (int t = 0; t < n / 2 * k; t++) {
auto [val, idx] = q.top(); q.pop();
ans2 += val;
assert(at[idx] >= 0);
if (--at[idx] >= 0) {
q.push({a[idx][at[idx]] + a[idx][m - (k - at[idx])], idx});
}
}
vector<vector<int>> ans(n, vector<int>(m, -1));
for (int i = 0, u = 0; i < n; i++) {
for (int j = 0; j <= at[i]; j++) {
ans[i][j] = u;
u = (u + 1) % k;
}
}
for (int i = 0; i < n; i++) {
int g = k - at[i] - 1;
vector<bool> used(k);
for (int j = 0; j <= at[i]; j++) used[ans[i][j]] = 1;
int on = 0;
for (int j = m - g; j < m; j++) {
while (on < k && used[on]) on++;
assert(on < k);
ans[i][j] = on++;
}
}
allocate_tickets(ans);
return ans2;
}
# | 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... |