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>
using namespace std;
int a,b,t,x[50001],y[50001],w[1000001],s[1000001],ch[1000001],idx[1000001],idx2[1000001];
priority_queue <pair <int, int>> q;
bool check(int val){
memset(ch,0,sizeof(ch));
q=priority_queue <pair <int, int>>();
int i=0;
for (int j=0;j<a;j++){
while (i<t&&w[idx[i]]<x[j]){
q.push({s[idx[i]],idx[i]});
i++;
}
for (int k=0;k<val;k++){
if (q.empty())
break;
ch[q.top().second]=1;
q.pop();
}
}
if (!b){
for (int i=0;i<t;i++)
if (!ch[i])
return false;
return true;
}
i=0;
int cnt=0;
for (int j=0;j<b;j++){
while (i<t){
if (!ch[idx2[i]]&&s[idx2[i]]>=y[j])
break;
cnt+=(!ch[idx2[i]]);
i++;
}
cnt=max(cnt-val,0);
}
return (i>=t&&!cnt);
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){
a=A,b=B,t=T;
for (int i=0;i<a;i++)
x[i]=X[i];
for (int i=0;i<b;i++)
y[i]=Y[i];
for (int i=0;i<t;i++){
idx[i]=idx2[i]=i;
w[i]=W[i];
s[i]=S[i];
}
sort(idx,idx+t,[](int i, int j){return w[i]<w[j];});
sort(idx2,idx2+t,[](int i, int j){return s[i]<s[j];});
sort(x,x+a);
sort(y,y+b);
int l=0,r=T,kq=-1;
while (l<=r){
int mid=(l+r)>>1;
if (check(mid)){
kq=mid;
r=mid-1;
}
else
l=mid+1;
}
return kq;
}
# | 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... |