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;
deque<pair<int,int>> toy,temp;
bool check(int A,int B,int T,int X[], int Y[],int lim){
toy=temp;
priority_queue<int> v;
for (int i = 0; i < A; ++i)
{
while(toy.size()){
if(toy[0].first>=X[i])
break;
v.push(toy[0].second);
toy.pop_front();
}
int cnt=0;
while(v.size() && cnt<lim){
cnt++;
v.pop();
}
}
for(auto i:toy)
v.push(i.second);
toy.clear();
stack<int> sz;
while(v.size()){
sz.push(v.top());
v.pop();
}
int p=0;
int cnt=0;
int i=0;
while(sz.size() && p<B){
if(sz.top()>=Y[p]){
p++;
cnt=0;
}
else if(cnt==lim){
p++;
cnt=0;
}
else{
cnt++;
sz.pop();
}
}
if(sz.size()==0)
return 1;
return 0;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){
int maxX=0,maxY=0;
for (int i = 0; i < A; ++i)
maxX=max(maxX,X[i]);
for (int i = 0; i < B; ++i)
maxY=max(maxY,Y[i]);
for (int i = 0; i < T; ++i){
if(W[i]>=maxX && S[i]>=maxY)
return -1;
temp.push_back({W[i],S[i]});
}
sort(temp.begin(), temp.end());
sort(X,X+A);
sort(Y,Y+B);
int low=0,high=T;
while(high-low>1){
int mid=(low+high)/2;
if(check(A,B,T,X,Y,mid))
high=mid;
else
low=mid;
}
return high;
}
Compilation message (stderr)
robots.cpp: In function 'bool check(int, int, int, int*, int*, int)':
robots.cpp:32:6: warning: unused variable 'i' [-Wunused-variable]
32 | int i=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... |