# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
527647 | Deepesson | Carnival Tickets (IOI20_tickets) | C++17 | 765 ms | 93252 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "tickets.h"
void allocate_tickets( std::vector<std::vector<int>> _d);
typedef std::pair<int,int> pii;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int N=x.size(),M=x[0].size();
int lado=(k*N)/2;
int pegou[N]={};
std::priority_queue<pii> queue;
std::vector<std::deque<int>> copia;
for(int i=0;i!=N;++i){
std::deque<int> k;
for(auto&z:x[i])k.push_back(z);
copia.push_back(k);
}
long long res=0;
std::deque<int> remove[N];
for(int i=0;i!=N;++i){
for(int j=0;j!=k;++j){
remove[i].push_back(x[i][j]);
res-=x[i][j];
}
}
for(int i=0;i!=N;++i){
if(remove[i].size()){
queue.push({remove[i].back()+copia[i].back(),i});
}
}
std::vector<int> pega[N]={};
for(int i=0;i!=lado;++i){
auto __ = queue.top();
queue.pop();
res+=__.first;
copia[__.second].pop_back();
pega[__.second].push_back(copia[__.second].size());
remove[__.second].pop_back();
if(remove[__.second].size()){
queue.push({remove[__.second].back()+copia[__.second].back(),__.second});
}
}
std::vector<std::vector<int>> ordem;
for(int i=0;i!=N;++i){
std::vector<int> p;
for(int j=0;j!=M;++j)p.push_back(-1);
ordem.push_back(p);
}
int adds[k]={},subs[k]={};
for(int i=0;i!=N;++i){
int rem = remove[i].size();
int cur=0;
std::vector<int> falta;
std::vector<pii> tem;
for(int i=0;i!=k;++i){
tem.push_back({subs[i],i});
}
std::sort(tem.begin(),tem.end());
bool foi[k]={};
///Remove
for(int j=0;j!=rem;++j){
if(subs[tem[cur].second]<(N/2)){
//std::cout<<"Adder "<<cur<<"\n";
foi[tem[cur].second]=1;
subs[tem[cur].second]++;
ordem[i][j]=tem[cur].second;
}else {falta.push_back(tem[cur].second);--j;}
++cur;
}
while(cur<k){falta.push_back(tem[cur].second);++cur;}
cur=0;
///Adiciona
for(int j=copia[i].size();j!=x[i].size();++j){
//std::cout<<"Add "<<falta[cur]<<"\n";
ordem[i][j]=falta[cur];
++cur;
}
// std::cout<<"\n";
}
allocate_tickets(ordem);
return res;
}
Compilation message (stderr)
# | 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... |