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;
using ll = long long;
ll find_maximum(int K, vector<vector<int>> X) {
int N = X.size(), M=X[0].size();
ll R=0;
vector<int> T(N), l(N), r(N);
priority_queue<pair<int, int>> pq;
for (int i=0; i<N; i++) {
pq.emplace(X[i][M-1]+X[i][K-1], i);
for (int j=0; j<K; j++) R-=X[i][j];
}
for (int i=0; i<K*N/2; i++) {
int j=pq.top().second;
R+=pq.top().first;
pq.pop();
T[j]++;
if (T[j]<K)
pq.emplace(X[j][M-1-T[j]]+X[j][K-1-T[j]], j);
}
vector<vector<int>> A;
while (pq.size()) pq.pop();
for (int i=0; i<N; i++)
A.emplace_back(vector<int>(M, -1)),
pq.emplace(T[i], i);
for (int i=0; i<K; i++) {
vector<int> chk(N);
for (int j=0; j<N/2; j++) chk[pq.top().second]=1, pq.pop();
for (int j=0; j<N; j++) {
if (chk[j]) {
l[j]++;
A[j][M-l[j]]=i;
pq.emplace(T[j]-l[j], j);
}
else A[j][r[j]]=i, r[j]++;
}
}
allocate_tickets(A);
return R;
}
# | 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... |