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 <bits/stdc++.h>
#include "tickets.h"
using namespace std;
using ll = long long;
#define MAXN (1000005)
long long find_maximum(int k, vector<vector<int>> x) {
ll N = x.size();
ll M = x[0].size();
vector<ll> val;
for(ll i = 0;i < N;i++){
for(ll j = 0;j < M;j++){
val.push_back(x[i][j]);
}
}
sort(val.begin(),val.end());
pair<ll,ll> mini = {1e18,-1};
for(auto b : val){
ll sum = 0;
for(ll i = 0;i < N;i++){
ll maximum = -1e18;
for(ll j = 0;j < M;j++){
maximum = max(maximum,abs(b - x[i][j]));
}
sum += maximum;
}
mini = min(mini,{sum,b});
}
vector<vector<int> > ans;
for(ll i = 0;i < N;i++){
vector<int> row;
for(ll j = 0;j < M;j++){
row.push_back(-1);
}
ans.push_back(row);
}
for(ll i = 0;i < N;i++){
ll maximum = -1e18;
ll ind = -1;
for(ll j = 0;j < M;j++){
if(maximum <= abs(mini.second - x[i][j])){
maximum = abs(mini.second - x[i][j]);
ind = j;
}
}
ans[i][ind] = 0;
}
allocate_tickets(ans);
return mini.first;
}
# | 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... |