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 <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
ll find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
ll val = 1e18;
std::vector<std::vector<int>> answer;
vector<int> temp;
for (int i = 0; i < n; i++) {
std::vector<int> row(m,-1);
row[0] = 0;
temp.push_back(x[i][0]);
answer.push_back(row);
}
sort(temp.begin(),temp.end());
int mid = (n/2)-1;
ll midV = temp[mid] + temp[mid+1];
for(int j=0;j<2;j++){
ll cur = 0;
for (int i = 0; i < n; i++) cur += abs(((midV+j)/2) - temp[i]);
val = min(val,cur);
}
allocate_tickets(answer);
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... |