제출 #526057

#제출 시각아이디문제언어결과실행 시간메모리
526057Deepesson로봇 (IOI13_robots)C++17
76 / 100
3014 ms6424 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...