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;
long long A[1505][1505], B[1505], C[1505];
vector< tuple<long long,long long,long long> > lst;
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) {
long long cnt = 0;
for (long long i = 0; i < N; ++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... |