이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
a[i].first = t[i][m - 1] + t[i][0];
}
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]];
a[i].first += t[a[i].second][bg[a[i].second] + 1];
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]];
a[i].first += t[a[i].second][end[a[i].second] - 1];
nw.push_back(t[a[i].second][end[a[i].second]]);
s[a[i].second][end[a[i].second]--] = r;
}
for (int i : nw) {
res += abs(i);
}
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... |