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;
int N = n*m;
vector<array<int, 2>> v;
for(int i=0;i<n;i++) for(int j=0;j<m;j++) {
v.push_back({x[i][j], i});
}
sort(v.begin(), v.end());
ll ans = 0;
vector<int> c(n, 0), L(n, 0);
for(int i=0;i<N/2;i++) c[v[i][1]]++, ans += v[i+N/2][0] - v[i][0];
vector<int> R = c;
priority_queue<array<int, 2>> pq;
for(int i=0;i<n;i++) pq.push({c[i], i});
vector<vector<int>> re(n, vector<int>(m, -1));
for(int i=0;i<m;i++) {
set<int> s;
for(int j=0;j<n/2;j++) s.insert(pq.top()[1]), pq.pop();
for(int j=0;j<n;j++) {
if(s.count(j)) re[j][L[j]++] = i;
else re[j][R[j]++] = i;
}
for(auto x : s) pq.push({--c[x], x});
}
allocate_tickets(re);
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... |