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;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
const int maxn = 1e6 + 5;
ll eval(vector<ll> v, ll x) {
ll S = 0;
for (ll a: v) {
S += abs(a-x);
}
return S;
}
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
assert(m==1);
vector<ll> v;
vector<vector<int>> ans(n, vector<int>(k));
for (int i=0; i<n; i++) {
for (int j=0; j<k; j++) {
ans[i][j] = 0;
v.push_back(x[i][j]);
}
}
sort(v.begin(), v.end());
allocate_tickets(ans);
return eval(v, v[(int)v.size() / 2]);
}
# | 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... |