이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
long long find_maximum(int k, vector<vector<int>> x) {
long long res = 0;
int n = x.size();
int m = x[0].size();
vector<vector<int>> ans(n, vector<int>(m, -1));
vector<pii> csts;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < k; ++j) {
res += x[i][m-1-j];
}
for (int j = 0; j < k; ++j) {
csts.push_back({x[i][j]+x[i][m-k+j],i});
}
}
vector<int> lcnt(n), hcnt(n, k);
sort(csts.begin(), csts.end());
for (int i = 0; i < n*k/2; ++i) {
res -= csts[i].first;
lcnt[csts[i].second]++;
hcnt[csts[i].second]--;
}
for (int i = 0; i < k; ++i) {
vector<int> vs(n);
iota(vs.begin(), vs.end(), 0);
sort(vs.begin(), vs.end(), [&](int a, int b) {return lcnt[a] > lcnt[b];});
for (int j = 0; j < n/2; ++j) {
lcnt[vs[j]]--;
ans[vs[j]][lcnt[vs[j]]] = i;
}
for (int j = n/2; j < n; ++j) {
hcnt[vs[j]]--;
ans[vs[j]][m-1-hcnt[vs[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... |