이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
#define V vector
#define VI V<int>
V<VI> genalloc(V<VI>ones,V<VI>negs,int n,int m,int k){
V<VI>ans(n,VI(m,-1));
for(int i=0;i<k;i++){
int cnto=0,cntn=0;
vector<int>netrl;
for(int j=0;j<n;j++){
if(negs[j].empty())
ans[j][ones[j].back()]=i,
ones[j].pop_back(),cnto++;
else if(ones[j].empty())
ans[j][negs[j].back()]=i,
negs[j].pop_back(),cntn++;
else netrl.push_back(j);
}
for(auto j:netrl)if(cnto<n/2)
ans[j][ones[j].back()]=i,
ones[j].pop_back(),cnto++;
else ans[j][negs[j].back()]=i,
negs[j].pop_back(),cntn++;
}
return ans;
}
long long find_maximum(int k, V<VI> x) {
int n = x.size();
int m = x[0].size();
priority_queue<pair<int,int>>pq;
long long ans=0;
V<VI> ones(n),negs(n);
for(int i=0;i<n;i++)for(int j=0;j<k;j++)
negs[i].push_back(j),ans-=x[i][j],
pq.push({x[i][j]+x[i][m-k+j],i});
for(int q=0;q<n*k/2;q++){
auto[x,y]=pq.top();
ones[y].push_back(m-k+negs[y].back());
negs[y].pop_back();pq.pop();ans+=x;
}
allocate_tickets(genalloc(ones,negs,n,m,k));
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... |