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;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size(), cnt[n] = {};
vector<vector<int>> answer(n, vi(m));
ii vals[n*m];
rep (i,0,n-1) rep (j,0,m-1) vals[i*m+j] = {x[i][j], i};
sort(vals, vals+n*m);
ll tot = 0;
rep (i,0,n*m-1) {
if (i<n*m/2) {
tot -= vals[i].fi;
cnt[vals[i].se]++;
}
else tot += vals[i].fi;
}
int id = 0;
rep (i,0,n-1) {
sort(x[i].begin(), x[i].end());
rep (j,0,m-1) answer[i][j] = (id+j)%m;
id += cnt[i];
}
allocate_tickets(answer);
return tot;
}
# | 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... |