이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define ll long long
ll find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> res;
res.resize(n);
for(int i = 0; i < n; i++) res[i].resize(m, -1);
ll ans = 0;
priority_queue<pii> q;
vector<int> pre(n, k), suf(n, 0);
for(int i = 0; i < n; i++){
for(int j = 0; j < k; j++){
ans -= x[i][j];
}
q.push({x[i][k - 1] + x[i][m - 1], i});
}
for(int z = 0; z < k * n / 2; z++){
pii a = q.top();
q.pop();
ans += a.first;
pre[a.second]--;
suf[a.second]++;
if(suf[a.second] == k) continue;
q.push({x[a.second][m - suf[a.second] - 1] + x[a.second][pre[a.second] - 1], a.second});
}
for(int r = 0; r < k; r++){
vector<pii> v;
for(int i = 0; i < n; i++){
v.push_back({suf[i], i});
}
sort(v.rbegin(), v.rend());
for(int i = 0; i < n / 2; i++){
res[v[i].second][m - v[i].first] = r;
suf[v[i].second]--;
}
for(int i = n / 2; i < n; i++){
res[v[i].second][pre[v[i].second] - 1] = r;
pre[v[i].second]--;
}
}
allocate_tickets(res);
return ans;
}
# | 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... |