This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |