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;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
typedef vector<int> vi;
typedef pair<int,int> ii;
long long find_maximum(int k, vector<vi> x) {
int n = x.size(), m = x[0].size();
long long ans = 0;
vector<vi> answer(n, vi(m, -1));
priority_queue<pair<int,int>> pq;
int used[n]={}, lo[n]={}, hi[n]={};
rep (i,0,n-1) {
rep (j,0,k-1) ans -= x[i][j];
pq.push({x[i][m-1]+x[i][k-1],i});
}
rep (i,1,n*k/2) {
int ma = pq.top().first, c = pq.top().second;
pq.pop();
ans += ma;
if (used[c]++<k-1) pq.push({x[c][m-1-used[c]]+x[c][k-1-used[c]],c});
}
ii used2[n] = {};
rep (i,0,n-1) used2[i] = {used[i],i};
rep (i,0,k-1) {
sort(used2, used2+n, greater<ii>());
rep (j,0,n/2-1) {
int c = used2[j].second;
used2[j] = {--used[j], c};
answer[c][m-1-hi[c]++] = i;
}
rep (j,n/2,n-1) {
int c = used2[j].second;
answer[c][lo[c]++] = i;
}
}
allocate_tickets(answer);
return ans;
}
# | 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... |