이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> answer(n, vector<int>(m, -1));
vector<int> all(n);
vector<int> np(n), pp(n, m);
vector<pair<int,int>> now;
ll Sum = 0;
vector<pair<ll,int>> q;
for (int i = 0 ; i < n ; ++ i) {
for (int j = 0 ; j < k ; ++ j) {
Sum -= x[i][j];
q.push_back({x[i][j] + x[i][m - k + j], i});
}
}
sort(q.rbegin(), q.rend());
for (int rep = 0 ; rep < n * k / 2 ; ++ rep) {
auto [val, i] = q[rep];
Sum += val;
all[i] += 2;
}
for (int c = 0 ; c < k ; ++ c) {
now.clear();
for (int i = 0 ; i < n ; ++ i) now.push_back({all[i], i});
sort(now.begin(), now.end());
for (int j = 0 ; j < n / 2 ; ++ j) {
int i = now[j].second;
answer[i][np[i]++] = c;
all[i]++;
}
for (int j = n / 2 ; j < n ; ++ j) {
int i = now[j].second;
answer[i][--pp[i]] = c;
all[i]--;
}
}
allocate_tickets(answer);
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... |