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 <bits/stdc++.h>
#include "robots.h"
using namespace std;
int putaway(int a, int b, int n, int x[], int y[], int w[], int s[]) {
sort(x,x+a);
sort(y,y+b);
for(int i=0;i<n;i++){
if((!a||w[i]>=x[a-1])&&(!b||s[i]>=y[b-1]))return -1;
}
pair<int,int> t[n];
for(int i=0;i<n;i++)t[i]={w[i],s[i]};
sort(t,t+n);
int l=0,r=n;
while(l<r){
int m=(l+r)/2;
int idx=0;
priority_queue<int> pq;
for(int i=0;i<a;i++){
while(idx<n&&t[idx].first<x[i]){
pq.push(t[idx].second);
idx++;
}
for(int c=0;c<m&&!pq.empty();c++){
pq.pop();
}
}
while(idx<n){
pq.push(t[idx].second);
idx++;
}
bool pos=1;
for(int i=b-1;i>-1;i--){
for(int c=0;c<m&&!pq.empty();c++){
if(pq.top()<y[i])pq.pop();
else{
pos=0;
break;
}
}
if(!pos)break;
}
pos&=pq.empty();
if(pos)r=m;
else l=m+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... |