이 제출은 이전 버전의 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});
}
vector<int> cnt1(m, 0), cnt2(m, 0);
for(int i = 0; i < n; ++i){
vector<bool> vis(m, false);
int j2 = 0, j3 = pos[i] + m - k;
for(int j = 0; j < k; ++j){
if(cnt1[j] == n / 2){
cnt2[j]++;
c[i][j3] = j;
j3++;
vis[j] = true;
}
else if(cnt2[j] == n / 2){
cnt1[j]++;
c[i][j2] = j;
j2++;
vis[j] = true;
}
}
for(int j = 0; j < k; ++j){
if(vis[j]) continue;
if(j3 != m){
cnt2[j]++;
c[i][j3] = j;
j3++;
}
else{
cnt1[j]++;
c[i][j2] = j;
j2++;
}
}
}
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... |