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;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> c(n, vector<int>(m, -1));
int iter = n / 2 * k;
priority_queue<array<int, 2>, vector<array<int, 2>>, greater<array<int, 2>>> pq;
long long ans = 0;
vector<int> pos(n, 0);
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.push({x[i][0] + x[i][m - k], i});
for(int i = 0; i < iter; ++i){
auto [sub, idx] = pq.top();
pq.pop();
ans -= sub;
pos[idx]++;
if(pos[idx] + m - k < m)
pq.push({x[idx][pos[idx]] + x[idx][pos[idx] + m - k], idx});
}
int idx = 0;
for(int i = 0; i < n; ++i){
int j1 = 0, j2 = pos[i] + m - k;
while(j1 != pos[i]){
c[i][j1] = idx;
idx++, j1++;
if(idx == k) idx = 0;
}
int idx2 = idx;
while(j2 != m){
c[i][j2] = idx2;
idx2++, j2++;
if(idx2 == k) idx2 = 0;
}
}
allocate_tickets(c);
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... |