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 <queue>
#include <algorithm>
using namespace std;
using pp=pair<int, int>;
using ll=long long;
int n, m, k;
int prog[1510];
priority_queue<pp> pq;
ll ans;
int pg(auto &x, int i, int j) {
return -x[i][j]-x[i][m-k+j];
}
int nc[1510];
#include <cassert>
ll find_maximum(int k_, vector<vector<int>> x) {
n = x.size(); m = x[0].size(); k = k_;
for(int i=0; i<n; ++i) for(int j=m-k; j<m; ++j) ans += x[i][j];
for(int i=0; i<n; ++i) pq.emplace(pg(x, i, 0), i);
for(int cnt=n*k/2; cnt--;) {
auto [tv, ti] = pq.top(); pq.pop();
ans += tv;
if (++prog[ti] != k) {
pq.emplace(pg(x, ti, prog[ti]), ti);
}
}
int lmax = -1, rmin = 1e9;
for(int i=0; i<n; ++i) {
int t = prog[i];
if (t) lmax = max(lmax, x[i][t-1]);
if (t != k) rmin = min(rmin, x[i][m-k+t]);
}
assert (lmax <= rmin);
for(int i=0; i<n; ++i) {
fill(x[i].begin(), x[i].end(), -1);
int t = prog[i];
int ai = 0, bi = m-1;
for(int j=0; j<k; ++j) {
if (ai < t && nc[j] != n/2) {
x[i][ai++] = j;
++nc[j];
} else {
x[i][bi--] = j;
}
}
}
allocate_tickets(x);
return ans;
}
Compilation message (stderr)
tickets.cpp:15:8: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
15 | int pg(auto &x, int i, int j) {
| ^~~~
# | 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... |