이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define R(i,n,...) for(int i=__VA_ARGS__+0; i<(n); ++i)
struct pii {
int x, i, j;
bool operator<(const pii b) const { return x<b.x; }
};
ll find_maximum(int K, vector<vector<int>> A) {
const int N=A.size();
const int M=A[0].size();
const int X=N*K/2;
ll sum=0;
vector<pii> B(N*K);
R(i, N) {
R(j, K) {
sum+=A[i][M-K+j];
B[i*K+j]={A[i][M-K+j]+A[i][j], i, j};
}
fill(begin(A[i]), end(A[i]), -1);
}
sort(begin(B), end(B));
vector<int> C(N), D(K), E(K);
int st=0;
R(i, X) sum-=B[i].x, C[B[i].i]++;
R(i, N) {
int k=0, ed=st+C[i], cnt=0;
R(j, K-C[i]) {
while((st<=k && k<ed) || E[k]==N/2) k++;
++E[A[i][M-j-1]=k++];
}
R(j, C[i]) cnt+=++D[A[i][j]=st+j]==N/2;
st+=cnt;
}
allocate_tickets(A);
return sum;
}
# | 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... |