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;
long long A[1505], B[1505];
priority_queue< pair<long long,long long> > pq;
pair<long long,long long> lst[1505];
long long find_maximum(int k, vector<vector<int>> x) {
long long N = x.size(), M = x[0].size(), val = 0;
for (long long i = 0; i < N; ++i) {
A[i] = k-1;
pq.emplace(x[i][k-1]+x[i][M-1],i);
for (long long j = 0; j < k; ++j) val -= x[i][j];
}
for (long long i = 0; i < k*N/2; ++i) {
val += pq.top().first;
long long n = pq.top().second; pq.pop();
A[n]--;
if (A[n] != -1) pq.emplace(x[n][A[n]]+x[n][A[n]+M-k],n);
}
for (long long i = 0; i < N; ++i) B[i] = A[i]+M-k+1, lst[i] = make_pair(M-B[i],i);
vector< vector<int> > ans (N, vector<int>(M,-1));
for (long long i = 0; i < k; ++i) {
sort(lst,lst+N);
for (long long j = 0; j < N/2; ++j) {
long long n = lst[j].second;
ans[n][A[n]] = i, A[n]--;
}
for (long long j = N/2; j < N; ++j) {
long long n = lst[j].second;
ans[n][B[n]] = i, B[n]++, lst[j].first--;
}
}
allocate_tickets(ans);
return val;
}
# | 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... |