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;
typedef long long ll;
int putaway(int A,int B,int n,int limX[],int limY[],int X[],int Y[])
{
sort(limX,limX+A);
sort(limY,limY+B);
vector<array<int,2>> v(n);
for(int i=0;i<n;i++) v[i]={X[i],Y[i]};
sort(v.begin(),v.end());
int l=0,r=n+1;
while(l<r-1)
{
int cnt=(l+r)/2;
priority_queue<int> q;
int idx=0;
for(int i=0;i<A;i++)
{
while(idx<n&&v[idx][0]<limX[i]) q.push(v[idx++][1]);
for(int j=0;j<cnt&&!q.empty();j++) q.pop();
}
while(idx<n) q.push(v[idx++][1]);
for(int i=B-1;i>=0;i--)
{
int c=cnt;
while(c>0&&!q.empty()&&q.top()<limY[i])
{
q.pop();
c--;
}
}
if(q.empty()) r=cnt;
else l=cnt;
}
return (r<=n?r:-1);
}
# | 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... |