#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
// sub2
assert(B == 0);
multiset<int> toys;
for (int i = 0; i < T; i++) {
toys.insert(W[i]);
}
multiset<int> robots;
for (int i = 0; i < A; i++) {
robots.insert(X[i]);
}
int resp = 0;
while (true) {
resp++;
vector<int> to_delete_robots;
vector<int> to_delete_toys;
for (int x: robots) {
auto it = toys.lower_bound(x);
if (it == toys.begin()) {
to_delete_robots.push_back(x);
} else {
it--;
to_delete_toys.push_back(*it);
}
}
for (int x: to_delete_robots) {
robots.erase(robots.find(x));
}
for (int x: to_delete_toys) {
toys.erase(toys.find(x));
}
if ((int) toys.size() == 0 || (int) robots.size() == 0) break;
}
if ((int) toys.size() != 0) return -1;
return resp;
}
# | 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... |