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;
void allocate_tickets(vector<vector<int>> s);
int64_t find_maximum(int k, vector<vector<int>> x) {
int n = (int) x.size(), m = (int) x[0].size();
vector<vector<int>> assign(n, vector<int>(m, -1));
int64_t ans = 0;
vector<pair<int, int>> c;
vector<int> take(n);
for(int i = 0; i < n; i++) {
for(int j = 0; j < k; j++) {
ans -= x[i][j];
}
for(int b = k - 1; b >= 0; b--) {
c.push_back({x[i][b + m - k] + x[i][b], i});
}
}
sort(c.begin(), c.end());
for(int i = 0; i < n * k / 2; i++) {
take[c.back().second]++;
ans += c.back().first;
c.pop_back();
}
int l = 0, r = k - 1;
for(int i = 0; i < n; i++) {
for(int j = 0; j < take[i]; j++) {
assign[i][m - 1 - j] = r;
--r;
if(r < 0) r += k;
}
for(int j = 0; j < k - take[i]; j++) {
assign[i][j] = l;
++l;
if(l == k) l -= k;
}
}
allocate_tickets(assign);
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... |