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>
#include "tickets.h"
using ll = long long;
using namespace std;
ll find_maximum(int k, vector<vector<int>> t) {
int n = t.size(), m = t[0].size();
vector<int> all;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
all.push_back(t[i][j]);
}
}
sort(all.begin(), all.end());
int middle = all[all.size() / 2];
ll res = 0;
vector<pair<ll, int>> a(n);
vector<int> bg(n, 0), end(n, m - 1);
vector<vector<int>> s(n, vector<int>(m, -1));
for (int i = 0; i < n; i++) {
a[i].first = 0;
a[i].second = i;
for (int j = 0; j < m; j++) {
t[i][j] -= middle;
res += abs(t[i][j]);
a[i].first += t[i][j];
}
}
for (int r = 0; r < k; r++) {
vector<int> nw;
sort(a.begin(), a.end());
for (int i = 0; i < n / 2; i++) {
a[i].first -= t[a[i].second][bg[a[i].second]];
nw.push_back(t[a[i].second][bg[a[i].second]]);
s[a[i].second][bg[a[i].second]++] = r;
}
for (int i = n / 2; i < n; i++) {
a[i].first -= t[a[i].second][end[a[i].second]];
nw.push_back(t[a[i].second][end[a[i].second]]);
s[a[i].second][end[a[i].second]--] = r;
}
assert(0 >= nw[n / 2 - 1] && 0 <= nw[n / 2]);
}
allocate_tickets(s);
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... |