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 find_maximum(int k, vector<vector<int>> x) {
int N = x.size();
int M = x[0].size();
vector<vector<int>> ans(N, vector<int>(M, -1));
vector<long long> sum(N);
for(int i = 0; i < N; ++i) {
for(auto& u : x[i]) {
sum[i] += u;
}
}
vector<int> ind(N); iota(begin(ind), end(ind), 0);
vector<vector<int>> qs(k);
vector<int> L(N, 0), R(N, M - 1);
for(int i = 0; i < k; ++i) {
vector<bool> is(N);
int sum = 0;
for(int j = 0; j < N && sum < N / 2; ++j) {
if(x[j][L[j]] == 0) {
is[j] = 1;
++sum;
}
}
for(int j = 0; j < N; ++j) {
if(is[j]) {
ans[j][L[j]] = i;
qs[i].push_back(x[j][L[j]]);
++L[j];
} else {
ans[j][R[j]] = i;
qs[i].push_back(x[j][R[j]]);
--R[j];
}
}
}
allocate_tickets(ans);
long long D = 0;
for(auto& u : qs) {
sort(begin(u), end(u));
for(auto& v : u) {
D += abs(v - u[N / 2]);
}
}
return D;
}
# | 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... |