#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]){
vector<int> x(a);
for(int i = 0; i < a; i++){
x[i] = X[i];
}
vector<int> y(b);
for(int i = 0; i < b; i++){
y[i] = Y[i];
}
vector<pair<int, int>> w(t);
for(int i = 0; i < t; i++){
w[i].first = W[i];
}
for(int i = 0; i < t; i++){
w[i].second = S[i];
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
sort(w.begin(), w.end());
int low = 1;
int top = t;
int ns = -1;
while(low <= top){
int mid = (low + top)/2;
int it = 0;
multiset<int> m;
for(int i = 0; i < t; i++){
while(it < a){
if(x[it] <= w[i].first){
for(int y = 0; y < mid; y++){
if(m.size() == 0) break;
m.erase(prev(m.end()));
}
it++;
}else{
break;
}
}
m.insert(w[i].second);
}
for(int y = it; y < a; y++){
for(int i = 0; i < mid; i++){
if(m.size() == 0) break;
m.erase(prev(m.end()));
}
}
it = 0;
int h = 0;
bool z = true;
for(auto i : m){
while(it < b){
if(y[it] <= i || h == mid){
it++;
h = 0;
}else{
break;
}
}
if(it == b){
z = false;
break;
}
h++;
}
if(z){
ns = mid;
top = mid-1;
}else{
low = mid+1;
}
}
//1e6 * 20 * 20
return ns;
}
# | 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... |