이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1500 + 3;
vector<vector<int>> x, answer;
int n, m, k, idx[N];
array<int, 2> arr[N];
void clear(){
}
ll solve(){
clear();
ll ans = 0;
priority_queue<array<int, 2>> pq;
int add = n * k / 2;
for(int i = 0; i < n; ++i){
idx[i] = 0;
pq.push({-x[i][0] - x[i][m - k], i});
}
while(add--){
auto [score, i] = pq.top();
pq.pop();
idx[i]++;
if(idx[i] < k)
pq.push({-x[i][idx[i]] - x[i][m - k + idx[i]], i});
}
for(int i = 0; i < n; ++i){
for(int j = 0; j < idx[i]; ++j){
answer[i][j] = 1;
ans -= x[i][j];
}
for(int j = idx[i] + m - k; j < m; ++j){
answer[i][j] = 2;
ans += x[i][j];
}
}
int cnt_1 = 0, cnt_2 = 0;
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
if(answer[i][j] == -1) continue;
if(answer[i][j] == 1){
answer[i][j] = cnt_1;
cnt_1 = (cnt_1 + 1) % k;
cnt_2 = cnt_1;
}
else{
answer[i][j] = cnt_2;
cnt_2 = (cnt_2 + 1) % k;
}
}
}
return ans;
}
long long find_maximum(int _k, vector<vector<int>> _x) {
k = _k;
x = _x;
n = x.size();
m = x[0].size();
answer.clear();
answer.resize(n, vector<int>(m, -1));
ll ans = solve();
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... |