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 pii pair<int,int>
#define x first
#define y second
using namespace std;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
vector<pii> v;
for(int i=0;i<T;i++) v.push_back({W[i],S[i]});
sort(X,X+A);
sort(Y,Y+B);
sort(v.begin(),v.end());
auto ok=[&](int mid)
{
priority_queue<pii> PQ;
vector<int> resen(T);
int j=0;
for(int i=0;i<A;i++)
{
int vreme=0;
while(j<T && X[i]>v[j].x)
{
j++;
PQ.push({v[j].y,j});
}
while(!PQ.empty() && vreme<mid)
{
++vreme;
resen[PQ.top().y]=1;
PQ.pop();
}
}
while(j<T)
{
j++;
PQ.push({v[j].y,j});
}
for(int i=B-1;i>=0;i--)
{
int vreme=0;
while(!PQ.empty() && vreme<mid && PQ.top().x<Y[i])
{
vreme++;
resen[PQ.top().y]=1;
PQ.pop();
}
};
for(int i=0;i<T;i++) if(!resen[i]) return 0;
return 1;
};
int l=0;
int r=T;
int odg=-1;
while(l<=r)
{
int mid=(l+r)/2;
if(ok(mid))
{
odg=mid;
l=mid+1;
}
else r=mid-1;
}
return odg;
}
# | 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... |