이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "tickets.h"
using namespace std;
int n ,m ,k;
vector <vector <int>> x;
vector <vector <int>> construct(vector <int> pref){
vector <array <int ,3>> fh[n] ,sh;
for(int i = 0; i < n; i++){
for(int j = 0; j < pref[i]; j++)
fh[i].push_back({x[i][j] ,i ,j});
for(int j = m-1; j >= m - (k-pref[i]); j--)
sh.push_back({x[i][j] ,i ,j});
}
vector<vector<int>> answer(n ,vector<int>(m ,-1));
vector<bitset<1500>> taken(n);
for(auto&bs : taken) bs.set();
int round_number = 0;
for(int i = 0; i < n; i++)
for(auto&c : fh[i]){
answer[c[1]][c[2]] = round_number;
taken[c[1]][round_number] = false;
round_number = (round_number+1 == k? 0 : round_number+1);
}
vector <int> pos(n ,-1);
for(auto&c : sh){
pos[c[1]] = taken[c[1]]._Find_next(pos[c[1]]);
answer[c[1]][c[2]] = pos[c[1]];
}
return answer;
}
long long find_maximum(int _k, vector<vector<int>> _x) {
x = _x;
n = x.size();
m = x[0].size();
k = _k;
vector <int> pref(n ,k);
priority_queue <pair <int64_t ,int>> pq;
int64_t tot = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < pref[i]; j++)
tot -= x[i][j];
pq.push({x[i][pref[i]-1] + x[i][m-1-(k - pref[i])] ,i});
}
for(int step = 0; step < n*k/2; step++){
auto p = pq.top(); pq.pop();
tot += p.first;
int i = p.second;
pref[i]--;
if(pref[i])
pq.push({x[i][pref[i]-1] + x[i][m-1-(k - pref[i])] ,i});
}
allocate_tickets(construct(pref));
return tot;
}
# | 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... |