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
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,j;i<a;i++){
for(;tt<t&&toy[tt].fr<x[i];tt++)q.push({toy[tt].sc});
for(j=0;j<m&&!q.empty();j++)q.pop();
}
for(int i=t-1;i>=0&&toy[i].fr>=(a?x[a-1]:0);i--)q.push({toy[i].sc});
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;
memcpy(x,X,a);
memcpy(y,Y,b);
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... |