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;
#include <vector>
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
long long sum = 0;
vector<int>pos;
for (int i = 0;i<n;++i){
for (int j = 0;j<m;++j){
sum+=x[i][j];
pos.push_back(x[i][j]);
x[i][j] = 0;
}
}
sort(pos.begin(),pos.end());
vector<int>valid = {pos[n/2]};
long long ans = LLONG_MAX;
for (auto x:valid){
long long curans = 0;
for (auto y:pos){
curans+=abs(y - x);
}
ans = min(ans,curans);
}
for (int i = 0;i<n;++i){
for (int j = 0;j<m;++j){
x[i][j] = 0;
}
}
allocate_tickets(x);
return ans;
}
# | 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... |