이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
#define p pair
#define pq priority_queue
#define v vector
#define card pair<long long,pair<long long,long long>>
long long find_maximum(int k, v<v<int>> x) {
long long out=0;
long long n=x.size();//num colours
long long m=x[0].size();//num of each colour
pq<card> mi;
v<v<card>> l(n);
v<v<card>> s(n);
v<v<int>> answer(n,v<int>(m,-1));
for(long long i=0;i<n;i++){//initilize long list
pq<card> ma;
for(long long j=0;j<m;j++){
ma.push({x[i][j],{i,j}});
mi.push({-x[i][j],{i,j}});
}
for(long long j=0;j<k;j++){
card cur=ma.top();
ma.pop();
l[i].push_back(cur);
}
}
long long count=0;
while(count<k*n/2){//transfer to short list
card cur = mi.top();
mi.pop();
long long colInd=cur.second.first;
if(l[colInd].size()>0){
l[colInd].pop_back();
s[colInd].push_back({-cur.first,cur.second});
count++;
}
}
for(int i=0;i<k;i++){//allocate
long long sm=0;
long long la=0;
for(long long j=0;j<n;j++){
bool takeL=true;
if(sm==n/2){
takeL=true;
}
else if(la==n/2){
takeL=false;
}
else if(l[j].size()>0){
takeL=true;
}
else{
takeL=false;
}
if(takeL){
card cur=l[j][l[j].size()-1];
answer[j][cur.second.second]=i;
out+=cur.first;
l[j].pop_back();
la++;
}
else{
card cur=s[j][s[j].size()-1];
answer[j][cur.second.second]=i;
out-=cur.first;
s[j].pop_back();
sm++;
}
}
}
allocate_tickets(answer);
return out;
}
# | 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... |