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 "robots.h"
#include <bits/stdc++.h>
int putaway(int a, int b, int t, int *x, int *y, int *w, int *s) {
std::sort(x, x + a);
std::sort(y, y + b);
std::vector<int> ord(t); iota(ord.begin(), ord.end(), 0);
std::sort(ord.begin(), ord.end(), [&](int i, int j) {
return std::tie(w[i], s[i]) < std::tie(w[j], s[j]);
});
auto check = [&](int k) {
std::priority_queue<int> pq;
int j = 0;
for (int i = 0; i < a; ++i) {
while (j < t && w[ord[j]] < x[i]) {
pq.push(s[ord[j++]]);
}
int could = k;
while (pq.size() && could) {
pq.pop();
--could;
}
}
while (j < t) {
pq.push(s[ord[j++]]);
}
for (int i = b - 1; i; --i) {
int could = k;
while (pq.size() && pq.top() < y[i] && could) {
pq.pop();
--could;
}
}
return !pq.size();
};
int l = 0, r = t, res = -1;
while (l <= r) {
int m = (l + r) / 2;
if (check(m)) {
res = m;
r = m - 1;
} else {
l = m + 1;
}
}
return res;
}
# | 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... |