이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
/*
at every round we choose n / 2 mins and n / 2 maxs
value of round is sum_of_maxs - sum_of_mins
mx[i] + mn[i] > mx[j] + mn[j]
^ wrong
just image taking k mins and then find diffs next max - last min
sort everything and take greedy
works?
*/
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size(), m = x[0].size();
vector<vector<int>> ans(n, vector<int>(m, -1));
long long sum = 0;
vector<tuple<long long, int, int, int>> ops;
for (int i = 0; i < n; i++) {
for (int j = 0; j < k; j++) {
sum -= x[i][j];
ans[i][j] = j;
}
for (int j = k - 1; j >= 0; j--) {
ops.emplace_back(x[i][j] + x[i][m - (k - j)], i, j, m - (k - j));
}
}
int take = n / 2 * k;
sort(ops.rbegin(), ops.rend());
for (int id = 0; id < take; id++) {
sum += get<0>(ops[id]);
int i = get<1>(ops[id]);
int jx = get<2>(ops[id]);
int jy = get<3>(ops[id]);
swap(ans[i][jx], ans[i][jy]);
}
allocate_tickets(ans);
return sum;
}
# | 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... |