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 a,b,t,x[50000],y[50000];
pair<long long,int> w[1000000],s[1000000];
long long wg[1000000],sz[1000000];
struct edge1
{
long long w,s,id;
edge1(){}
edge1(long long _w,long long _s,long long i)
{
w=_w;
s=_s;
id=i;
}
bool operator<(const edge1&e)const
{
return e.s<s;
}
};
priority_queue<edge1> q;
int used[1000000];
bool smart(int k)
{
//cout<<k<<" * "<<endl;
memset(used,0,sizeof(used));
int id=0,in=0;
for(int i=0;i<a;i++)
{
int cnt=0;
while(id<t&&w[id].first<x[i])
{
int idx=w[id].second;
q.push({wg[i],sz[i],idx});
id++;
}
while(cnt<k&&q.size())
{
int t=q.top().id;
//cout<<"/ "<<t<<endl;
q.pop();
cnt++;
used[t]=1;
in++;
}
}
//cout<<"pout"<<endl;
id=0;
for(int i=0;i<b;i++)
{
int cnt=0;
while(id<t&&s[id].first<y[i]&&cnt<k)
{
int idx=s[id].second;
if(!used[idx])
{
cnt++;
used[idx]=1;
in++;
}
id++;
}
}
/*for(int i=0;i<t;i++)
cout<<used[i]<<" ";
cout<<endl;*/
while(q.size())q.pop();
if(in==t)return 1;
return 0;
}
// sort by s in pq, sort by w in va
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++)
w[i].first=W[i],s[i].first=S[i],w[i].second=s[i].second=i,wg[i]=W[i],sz[i]=S[i];
sort(x,x+a);
sort(y,y+b);
sort(w,w+t);
sort(s,s+t);
int l=1,r=t;
int ans=-1;
while(l<=r)
{
int m=(l+r)/2;
if(smart(m))
{
ans=m;
r=m-1;
}
else l=m+1;
}
return ans;
}
# | 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... |