이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long A[1505][1505], B[1505], C[1505];
vector< tuple<long long,long long,long long> > lst;
bitset<1505> bs;
long long find_maximum(int k, vector<vector<int>> x) {
long long N = x.size(), M = x[0].size();
for (long long i = 0; i < N; ++i) for (long long j = 0; j < M; ++j) lst.emplace_back(x[i][j],i,j);
sort(lst.begin(),lst.end());
memset(A,0,sizeof(A));
for (long long i = 0; i < N*M/2; ++i) A[get<1>(lst[i])][get<2>(lst[i])] = 1;
memset(B,0,sizeof(B)); memset(C,0,sizeof(C));
for (long long i = 0; i < N; ++i) {
while (C[i] < M && A[i][C[i]] == 1) C[i]++;
}
long long val = 0;
vector< vector<int> > ans (N, vector<int>(M,-1));
for (long long j = 0; j < M; ++j) {
bs.reset();
long long cnt = 0;
for (long long i = 0; i < N; ++i) {
if (B[i] == M || A[i][B[i]] == 0) ans[i][C[i]] = j, val += x[i][C[i]], C[i]++, bs[i] = 1;
else if (C[i] == M) ans[i][B[i]] = j, cnt++, val -= x[i][B[i]], B[i]++, bs[i] = 1;
}
for (long long i = 0; i < N; ++i) if (!bs[i]) {
if (cnt < N/2 && A[i][B[i]] == 1) ans[i][B[i]] = j, cnt++, val -= x[i][B[i]], B[i]++;
else ans[i][C[i]] = j, val += x[i][C[i]], C[i]++;
}
}
allocate_tickets(ans);
return val;
}
# | 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... |