제출 #18907

#제출 시각아이디문제언어결과실행 시간메모리
18907ggoh로봇 (IOI13_robots)C++98
0 / 100
0 ms13328 KiB
#include "robots.h"
#include<set>
#include<algorithm>
int a,b,c,i,p,q,h,o,t;
struct AA{
    int x,y;
}data[1000002];
bool cmp(AA aa,AA bb){return aa.x<bb.x;}
std::set<int>s;
std::set<int>::iterator it;
int putaway (int A, int B, int T, int X[], int Y[], int W[], int S[])
{
    a=A;b=B;c=T;
    std::sort(X,X+a);
    std::sort(Y,Y+b);
    for(i=0;i<c;i++)
    {
        if(W[i]>X[a-1]&&S[i]>Y[b-1])
        {
            return -1;
        }
    }
    q=c;
    p=0;
    for(i=0;i<c;i++)data[i]={W[i],S[i]};
    std::sort(data,data+c,cmp);
    while(p!=q-1)
    {
        h=(p+q)/2;
        s.clear();
        o=0;
        for(i=0;i<a;i++)
        {
            while(o<c&&data[o].x<X[i])s.insert(data[o].y),o++;
            t=h;
            while(t&&!s.empty())
            {
                it=s.end();
                it--;
                s.erase(it);
                t--;
            }
        }
        while(o<c)s.insert(data[o].y),o++;
        for(i=0;i<b;i++)
        {
            if(s.empty())break;
            t=h;
            while(t&&!s.empty())
            {
                it=s.begin();
                if((*it)<Y[i])
                {
                    t--;
                    s.erase(it);
                }
                else break;
            }
        }
        if(s.empty())q=h;
        else p=h;
    }
    return q;
}
#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...