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;
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;
all[i]++;
}
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... |