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<iostream>
#include<algorithm>
#include<queue>
#include"robots.h"
using namespace std;
int putaway(int A,int B,int T,int x[],int y[],int W[],int S[])
{
vector<pair<int,int> > zabawki;
for(int i=0;i<T;i++)
zabawki.push_back({W[i],S[i]});
sort(zabawki.begin(),zabawki.end());
vector<int> X,Y;
for(int i=0;i<A;i++)
X.push_back(x[i]);
for(int i=0;i<B;i++)
Y.push_back(y[i]);
sort(X.begin(),X.end());
sort(Y.begin(),Y.end());
int pocz=1,kon=T+1,sre,ostd=-1;
while(pocz<kon)
{
sre=(pocz+kon)/2;
int gdzie=0;
priority_queue<int> kolejka;
for(int i=0;i<A;i++)
{
while(gdzie<T && zabawki[gdzie].first<X[i])
kolejka.push(zabawki[gdzie].second),gdzie++;
for(int j=0;j<sre;j++)
if(!kolejka.empty())
kolejka.pop();
else break;
}
while(gdzie<T)
kolejka.push(zabawki[gdzie].second),gdzie++;
for(int i=B-1;i>=0;i--)
{
if(kolejka.empty())
break;
if(Y[i]<=kolejka.top())
break;
for(int j=0;j<sre;j++)
if(!kolejka.empty())
kolejka.pop();
else break;
}
if(kolejka.empty())
{
ostd=sre;
kon=sre;
}
else pocz=sre+1;
}
return ostd;
}
# | 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... |