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;
#define pb push_back
#define se second
#define fi first
long long sum(vector<int> tab){
int n=tab.size();
long long res=0;
sort(tab.begin(),tab.end());
for (long long i = 0; i < n; ++i)
{
res+=abs(tab[i]-tab[n/2]);
}
return res;
}
long long find_maximum(int k, std::vector<std::vector<int>> x) {
long long n = x.size();
int m = x[0].size();
vector<std::vector<int>> ans(n,vector<int> (m,-1));
long long res=0;
vector<pair<int,int>> mx;
vector<pair<int,int>> mn;
for (int i = 0; i < n; ++i)
{
mx.pb({x[i][m-1],i});
mn.pb({x[i][0],i});
}
vector<int> tab;
sort(mx.begin(),mx.end());
sort(mn.begin(),mn.end());
for (int i = 0; i < n/2; ++i)
{
ans[mn[i].se][0]=0;
ans[mx[i+n/2].se][m-1]=0;
tab.pb(mx[i+n/2].fi);
tab.pb(mn[i].fi);
}
allocate_tickets(ans);
res+=sum(tab);
return res;
}
# | 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... |