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 "tickets.h"
using namespace std;
#define ll long long
#define sz(a) (int)a.size()
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define forn(i, n) for(int i=0;i < n; ++i)
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
std::vector<std::vector<int>> answer(n, vector<int>(m, -1));
vector<int> use_left(n, 0), l(n, 0), r(n, m - 1);
set<pair<int, int>> s;
ll ans = 0;
for(int i = 0; i < n; ++i) {
s.insert({x[i][0] + x[i][m - k], i});
}
for(int t = 0; t < n * k / 2; ++t) {
int i = (*s.begin()).second; s.erase(s.begin());
if(++use_left[i] < k) {
s.insert({x[i][use_left[i]] + x[i][m - k + use_left[i]], i});
}
}
for(int kk = 0; kk < k; ++kk) {
vector<pair<int, int>> a;
for(int i = 0; i < n; ++i) a.pb({use_left[i], i});
sort(rall(a));
for(int j = 0; j < n / 2; ++j) {
int i = a[j].second;
assert(use_left[i]);
ans -= x[i][use_left[i] - 1];
answer[i][use_left[i] - 1] = kk;
--use_left[i];
}
for(int j = n / 2; j < n; ++j) {
int i = a[j].second;
ans += x[i][r[i]];
answer[i][r[i]] = kk;
--r[i];
}
}
allocate_tickets(answer);
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... |