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 putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){
int l=1,p=(1e6)+1,md;
vector<pair<int,int>> vec;
sort(X,X+A);
sort(Y,Y+B,greater<int>());
for (int i = 0; i<T; i++)vec.push_back({W[i],S[i]});
sort(vec.begin(),vec.end());
priority_queue<int> pq;
while(l<p){
md=(l+p)/2;
int iter=0;
for (int i = 0; i<A; i++){
for (;iter<T && vec[iter].first<X[i];iter++)pq.push(vec[iter].second);
for (int j = 0; j<md && pq.size(); j++)pq.pop();
}
for (;iter<T; iter++)pq.push(vec[iter].second);
bool ok=true;
for (int i = 0; i<B && pq.size(); i++){
for (int j = 0; j<md && pq.size(); j++){
if (pq.top()>=Y[i])ok=false;
pq.pop();
}
}
if (pq.size())ok=false;
if (ok)p=md;
else l=md+1;
for (;pq.size();pq.pop());
}
return (l==((1e6)+1)?-1:l);
}
# | 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... |