This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include"robots.h"
#include<bits/stdc++.h>
#define fr first
#define sc second
//#include"grader.c"
using namespace std;
int a,b,t,x[50005],y[50005];
pair<int,int>toy[1000005];
bool check(int m){
priority_queue<int>q;
for(int i=0,tt=0;i<=a;i++){
for(;tt<t&&toy[tt].fr<x[i];tt++)q.push(toy[tt].sc);
if(i!=a)for(int j=0;j<m&&(!q.empty());j++)q.pop();
}
for(int i=b-1;i>=0&&(q.empty()||q.top()<y[i]);i--)
for(int j=0;j<m&&(!q.empty());j++)q.pop();
return q.empty();
}
int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){
a=A,b=B,t=T;
x[a]=2e9+1;
copy(X,X+A,x);
copy(Y,Y+B,y);
for(int i=0;i<t;i++)toy[i]={W[i],S[i]};
sort(x,x+a);
sort(y,y+b);
sort(toy,toy+t);
int l=1,r=t;
while(l<r){
int mid=(l+r)>>1;
if(check(mid))r=mid;
else l=mid+1;
}
if(!check(l))return -1;
return l;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |