Submission #409517

#TimeUsernameProblemLanguageResultExecution timeMemory
409517BelguteiRobots (IOI13_robots)C++17
0 / 100
1 ms332 KiB
#include "robots.h"
#include<bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define ll long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int l,r,ans,mid;
priority_queue<int> pq;
pair<int,int> p[1000005];
bool used[1000005];

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
	l=0;
	r=T;
	sort(X,X+A);
	sort(Y,Y+B);
	
	for(int i=0; i<T; i++){
		p[i].ff=W[i];
		p[i].ss=S[i];
	}
	sort(p,p+T);
	bool check=0;
	while(l<r){
		mid=(l+r)/2;
		int pos=0;
		// 0->(pos-1)
		while(pq.size()>0) pq.pop();
		bool ok=0;
		for(int i=0; i<A; i++){
			// X[i]
			for(int j=pos; j<T; j++){
				if(p[j].ff<X[i]){
					pq.push(p[j].ss);
				}
				else{
					ok=1;
					pos=j-1;
					break;
				}
			}
			if(ok==0) pos=T;
			int cnt=mid;
			while(cnt>0 && cnt-- && pq.size()>0){
				pq.pop();
			}
		}
		for(int i=pos; i<T; i++) pq.push(p[i].ss);
		for(int i=B-1; i>=0; i--){
			int cnt=mid;
			while(cnt>0 && cnt-- && pq.size()>0 && pq.top()<Y[i]){
				pq.pop();
			}
			if(cnt>0) break;
		}
		if(pq.size()==0){
			r=mid;
			check=1;
		}
		else l=mid+1;
	}
	if(check==0) return -1;
	else return l;
}
#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...