이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |