Submission #592446

#TimeUsernameProblemLanguageResultExecution timeMemory
592446BT21tata로봇 (IOI13_robots)C++17
28 / 100
165 ms4428 KiB
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
 
vector<int>pos[10];

bool check(int A, int T, int *x, int *w, int mid)
{
    int pos=0;

    for(int i=0; i<A; i++)
    {
        for(int j=0; j<mid; j++)
        {
            //cout<<mid<<' '<<pos<<' '<<w[pos]<<' '<<i<<' '<<x[i]<<endl;
            if(w[pos]<x[i])
                pos++;
            else break;
            if(pos==T) return 1;
        }
    }
    return 0;

}

int putaway(int A, int B, int T, int x[], int y[], int w[], int s[])
{   
    if(T==2 and A+B==2)
    {
        for(int i=0; i<T; i++)
        {
            for(int j=0; j<A; j++)
            {
                if(w[i]<x[j]) pos[i].push_back(j);
            }
            for(int j=0; j<B; j++)
            {
                if(s[i]<y[j]) pos[i].push_back(j+A);
            }
        }
        if(pos[0].size()==0 or pos[1].size()==0) return -1;
        int hv1=0, hv0=0;
        for(int i=0; i<T; i++)
        {
            for(int u : pos[i])
            {
                if(u==1) hv1=1;
                else hv0=1;
            }
        }
        if(!hv0 or !hv1) return 2;
    }
    else
    {
        sort(w, w+T);
        sort(x, x+A);
        if(w[T-1]>=x[A-1]) return -1;
        int l=1, r=T, mid;
        while(l<=r)
        {
            mid=(l+r)>>1;
            //cout<<mid<<' '<<check(A, T, x, w, mid)<<endl;
            if(check(A, T, x, w, mid)) r=mid-1;
            else l=mid+1;
        }
        return l;
    }
    return 1;
}
#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...