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;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
struct cell
{
int w,s;
bool operator<(const cell&a1)const
{
return s<a1.s;
}
};
bool cmp(cell a1,cell a2)
{
return a1.w<a2.w;
}
int n,m,t,a[1000005],b[1000005];
cell c[1000005];
priority_queue<cell>q;
bool check(int h)
{
int j=0;
for(int i=0;i<n;i++)
{
while(c[j].w<a[i]&&j<t)
{
q.push(c[j]);
j++;
}
int g=h;
while(g&&!q.empty())
{
q.pop();
g--;
}
}
for(;j<t;j++)q.push(c[j]);
for(int i=m-1;i>=0;i--)
{
int g=h;
if(!q.empty()&&q.top().s>=b[i])return false;
while(g&&!q.empty())
{
g--;
q.pop();
}
}
if(!q.empty())return false;
return true;
}
int putaway(int n,int m,int t,int a[],int b[],int w[],int s[])
//void read()
{
cin>>n>>m>>t;
for(int i=0;i<n;i++)
{
//cin>>a[i];
}
sort(a,a+n);
for(int i=0;i<m;i++)
{
//cin>>b[i];
}
sort(b,b+m);
for(int i=0;i<t;i++)
{
//cin>>c[i].w>>c[i].s;
c[i].w=w[i];
c[i].s=s[i];
}
sort(c,c+t,cmp);
int l=1,r=t,mi;
while(l<=r)
{
mi=(l+r)/2;
if(check(mi))r=mi-1;
else l=mi+1;
while(!q.empty())q.pop();
//cout<<l<<" "<<r<<endl;
}
if(l==t+1)
{
//cout<<-1<<endl;
return -1;
}
//cout<<l<<endl;
return l;
}
/*int main()
{
speed();
read();
return 0;
}
*/
# | 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... |