# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
544265 | krit3379 | Robots (IOI13_robots) | C++14 | 0 ms | 0 KiB |
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>
using namespace std;
#define N 1000005
struct A{
int w,s;
bool operator<(const A& o)const{
return s<o.s;
}
};
bool comw(A a,A b){
return a.w<b.w;
}
vector<A> p;
priority_queue<A> q;
int putaway(int a,int b,int t,int x[50005],int y[50005],int w[N],int s[N]){
int i,l,r,mid,now,cnt,ans;
sort(x,x+a);
sort(y,y+b);
for(i=0;i<t;i++){
if(w[i]>=x[a-1]&&s[i]>=y[b-1])return -1;
p.push_back({w[i],s[i]});
}
sort(p.begin(),p.end(),comw);
l=1,r=t;
while(l<=r){
mid=(l+r)/2;
now=0;
for(i=0;i<a;i++){
while(now<t&&p[now].w<x[i])q.push(p[now++]);
cnt=mid;
while(cnt--&&!q.empty())q.pop();
}
while(now<t)q.push(p[now++]);
for(i=b-1;i>=0;i--){
cnt=mid;
while(cnt--&&!q.empty()&&q.top().s<y[i])q.pop();
}
if(q.empty())ans=mid,r=mid-1;
else l=mid+1;
while(!q.empty())q.pop();
}
return ans;
}