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 <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#include "tickets.h"
#include <vector>
ll find_maximum(int k, vector<vector<int>> x) {
int n = (int)x.size();
int m = (int)x[0].size();
vector<vector<int>> answer(n, vector<int>(m, -1));
assert(k == 1);
vector<int> cnt(n);
for (int i = 0; i < n; ++i) {
cnt[i] = accumulate(all(x[i]), 0);
}
vector<int> ord(n);
iota(all(ord), 0);
sort(all(ord), [&](int i, int j) {
return cnt[i] < cnt[j];
});
for (int i = 0; i < n / 2; ++i) {
for (int j = 0; j < k; ++j) {
answer[ord[i]][j] = j;
}
}
for (int i = n / 2; i < n; ++i) {
for (int j = 0; j < k; ++j) {
answer[ord[i]][m - 1 - j] = j;
}
}
vector<vector<int>> res(k);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
// cout << answer[i][j] << " ";
if (answer[i][j] != -1) {
res[answer[i][j]].push_back(x[i][j]);
}
}
// cout << endl;
}
ll sum = 0;
for (int i = 0; i < k; ++i) {
sort(all(res[i]));
assert((int)res[i].size() == n);
for (int j = 0; j < n / 2; ++j) {
sum += res[i][n - 1 - j] - res[i][j];
}
}
allocate_tickets(answer);
return sum;
}
#ifdef LC
#include "grader.cpp"
#endif
# | 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... |