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 namespace std;
typedef long long ll;
typedef pair <int, int> pii;
ll find_maximum(int K, vector <vector <int>> x) {
int N = x.size();
int M = x[0].size();
ll sol = 0;
vector <pii> diffs;
for (int i = 0; i < N; i++)
for (int j = 1; j <= K; j++) {
diffs.push_back({x[i][K - j] + x[i][M - j], i});
sol -= x[i][K - j];
}
sort(diffs.begin(), diffs.end(), greater <pii> ());
vector <int> cnt(N);
for (int i = 0; i < K * N / 2; i++) {
cnt[diffs[i].second]++;
sol += diffs[i].first;
}
vector <int> lo(N, 0), hi(N, M - 1);
vector <vector <int>> round(N, vector <int> (M, -1));
for (int k = 0; k < K; k++) {
vector <pii> sorted;
for (int i = 0; i < N; i++)
sorted.push_back({cnt[i], i});
sort(sorted.begin(), sorted.end(), greater <pii> ());
for (int i = 0; i < N; i++) {
int colour = sorted[i].second;
if (i < N / 2) {
round[colour][hi[colour]--] = k;
cnt[colour]--;
}
else
round[colour][lo[colour]++] = k;
}
}
allocate_tickets(round);
return sol;
}
# | 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... |