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;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> ans;
for (int i = 0; i < n; i++) {
vector<int> row(m);
for (int j = 0; j < m; j++) {
if (j < k) {
row[j] = j;
} else {
row[j] = -1;
}
}
ans.push_back(row);
}
allocate_tickets(ans);
long long ret = 0;
vector<vector<int>> T(k);
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(ans[i][j] != -1) {
T[ans[i][j]].push_back(x[i][j]);
}
}
}
for(int i = 0; i < k; i++) {
sort(begin(T[i]), end(T[i]));
int p = T[i][n / 2];
for(int j = 0; j < n; j++) {
ret = ret + (long long)abs(p - T[i][j]);
}
}
/*for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
cout << ans[i][j] << " \n"[j == m - 1];
}
}*/
return ret;
}
# | 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... |