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 "robots.h"
typedef std::pair<int,int> pii;
int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){
std::sort(X,&X[A]);
std::sort(Y,&Y[B]);
int pesos[T]={};
for(int i=0;i!=A;++i){
for(int j=0;j!=T;++j){
if(W[j]<X[i]){
pesos[j]++;
}
}
}
for(int i=0;i!=B;++i){
for(int j=0;j!=T;++j){
if(S[j]<Y[i]){
pesos[j]++;
}
}
}
for(auto&x:pesos)if(!x)return -1;
int count=0,retirou=0;
bool pegou[T]={};
for(;;){
++count;
for(int i=0;i!=A;++i){
int pos=-1,valor = 1e9;
for(int j=0;j!=T;++j){
if(pegou[j])continue;
if(W[j]<X[i]){
if(pesos[j]<valor){
valor=pesos[j];
pos=j;
}
}
}
if(pos!=-1){
pegou[pos]=true;
++retirou;
}
}
for(int i=0;i!=B;++i){
int pos=-1,valor=1e9;
for(int j=0;j!=T;++j){
if(pegou[j])continue;
if(S[j]<Y[i]){
if(pesos[j]<valor){
valor=pesos[j];
pos=j;
}
}
}
if(pos!=-1){
pegou[pos]=true;
++retirou;
}
}
if(retirou==T){
break;
}
}
return count;
}
# | 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... |