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 <bits/stdc++.h>
using namespace std;
#define int long long
long long find_maximum(signed k, vector<vector<signed>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<signed>> answer(n, vector<signed>(m));
// vector<pair<int,int>> v;
// for(int i = 0; i < n; i++) {
// v.push_back({x[i], i});
// }
// sort(v.begin(), v.end());
// for(int i = 0; i < n)
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (j < k) {
answer[i][j] = j;
} else {
answer[i][j] = -1;
}
}
}
allocate_tickets(answer);
vector<vector<int>> rounds(k);
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
if(answer[i][j] != -1)
rounds[answer[i][j]].push_back(x[i][j]);
int ans = 0;
for(int i = 0; i < k; i++) {
if(rounds[i].empty()) continue;
int idx = rounds[i].size()/2;
for(auto x: rounds[i])
ans += abs(x - rounds[i][idx]);
}
return ans;
}
# | 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... |