이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |