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;
long long find_maximum(int k, vector<vector<int>> a) {
int n = (int)a.size(), m = (int)a[0].size();
long long res = 0;
vector<int> pl(n), pr(n, m - 1);
vector<vector<int>> ans(n, vector<int>(m, -1));
for (int i = 0; i < k; i++) {
vector<pair<int, int>> v;
for (int j = 0; j < n; j++) {
res -= a[j][pl[j]];
v.push_back({a[j][pr[j]] + a[j][pl[j]], j});
}
sort(v.begin(), v.end());
for (int j = 0; j < n / 2; j++) {
auto [x, p] = v[j];
ans[p][pl[p]++] = i;
}
for (int j = n / 2; j < n; j++) {
auto [x, p] = v[j];
res += x;
ans[p][pr[p]--] = 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... |