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 <ext/pb_ds/assoc_container.hpp>
//#include "grader.cpp"
#include "tickets.h"
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<pair <int, int> , null_type, less<pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
long long find_maximum(int k, vector <vector <int> > x) {
int n = sz(x);
int m = sz(x[0]);
vector <vector <int> > ans(n, vector <int> (m, -1));
vector <int> le(n, 0);
vector <int> ri(n, m - 1);
vector <int> M(n);
vector <vector <int> > used(k, vector <int> (n, 0));
ll sum = 0;
for (int it = 0; it < k; it++) {
vector <pair<int, int> > val;
for (int i = 0; i < n; i++) {
val.pb({x[i][le[i]] + x[i][m - k + it], i});
}
sort(all(val));
for (int i = 0; i < n / 2; i++) {
ans[val[i].S][le[val[i].S]] = it;
used[it][val[i].S] = 1;
sum -= x[val[i].S][le[val[i].S]];
le[val[i].S]++;
}
M[it] = x[val[n / 2 - 1].S][le[val[n / 2 - 1].S]];
}
for (int it = 0; it < k; it++) {
for (int i = 0; i < n; i++) {
if (used[it][i]) {
continue;
}
while (ri[i] >= 0 && ans[i][ri[i]] != -1) {
ri[i]--;
}
assert(ri[i] != -1 && x[i][ri[i]] >= M[it]);
used[it][i] = 1;
ans[i][ri[i]] = it;
sum += x[i][ri[i]];
}
}
allocate_tickets(ans);
return sum;
}
# | 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... |