제출 #1356352

#제출 시각아이디문제언어결과실행 시간메모리
1356352lizi14Robots (IOI13_robots)C++20
0 / 100
0 ms348 KiB
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;


int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
    sort(X,X+A);
    sort(Y,Y+B);
    int l=1,r=1e9;
    vector<pair<pair<int,int>,int>>v(T);
    for(int i=0; i<T; i++){
        v[i].first.first=W[i];
        v[i].first.second=S[i];
        v[i].second=i;
    }
    vector<pair<int,int>>p(T);
    for(int i=0; i<T; i++){
        p[i].first=S[i];
        p[i].second=i;
    }
    sort(p.begin(),p.end());
    sort(v.begin(),v.end());
   
    int ans=-1;
    while(l<=r){
        int mid=(l+r)/2;
        priority_queue<pair<int,int>>q;
        int k=0;
        int modz=0;
        int la[T];
        fill(la,la+T,0);
        for(int i=0; i<A; i++){
            for(int j=k; j<T; j++){
                if(v[j].first.first>=X[i]){
                    
                    k=j;
                    break;
                }
                else{
                    q.push({v[j].first.second,v[j].second});
                }
            }
            for(int j=0; j<mid; j++){
                if(q.size()>=1){
                    pair<int,int>h=q.top();
                    la[h.second]=1;
                    
                    q.pop();
                }
                else break;
            }
        }
        int y=0;
        priority_queue<int>qa;
        for(int i=0; i<B; i++){
            for(int j=y; j<T; j++){
                if(la[p[j].second]==0){
                    if(p[j].first>=Y[i]){
                        
                        y=j;
                        break;
                    }
                    else{
                        la[p[j].second]=1;
                        qa.push(p[j].first);
                    }
                }
            }
            for(int j=0; j<mid; j++){
                if(qa.size()>=1){
                    
                    qa.pop();
                }
                else{
                    break;
                }
            }
        }
        for(int i=0; i<T; i++){
            if(la[i]==0){
                modz=1;
                break;
            }
        }
        if(qa.size()==0 && modz==0){
            ans=mid;
            r=mid-1;
        }
        else{
            l=mid+1;
        }
        //cout<<ans<<endl;
    }
    return ans;
    //return 42;
}
#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...