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;
using LL = long long;
using pLL = array <LL, 2>;
using tLL = array <LL, 3>;
LL find_maximum(int k, vector<vector<int>> x) {
LL ans = 0;
int n = x.size(), m = x[0].size();
vector <pLL> A;
vector<vector<int>> s;
s.resize(n, vector <int> (m, -1));
priority_queue <tLL> pq;
for (int i = 0; i < n; i++) {
for (int j = 0; j < k; j++) {
ans -= x[i][j];
s[i][j] = j;
}
}
for (int i = 0; i < n; i++) pq.push({x[i][k - 1] + x[i][m - 1], i, k - 1});
for (int i = 0; i < n * k / 2; i++){
tLL now = pq.top(); pq.pop();
ans += now[0];
s[now[1]][now[2]] = -1;
s[now[1]][now[2] + m - k] = now[2];
if (now[2]) pq.push({x[now[1]][now[2] - 1] + x[now[1]][now[2] + m - k - 1], now[1], now[2] - 1});
}
allocate_tickets(s);
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... |