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;
const int T = 1000005;
struct item {
int w, s;
} v[T];
int putaway(int a, int b, int t,
int x[], int y[], int w[], int s[]) {
int maxw = *max_element(x, x + a);
int maxs = *max_element(y, y + b);
for (int i = 0; i < t; i++) {
if (a && w[i] < maxw) continue;
if (b && s[i] < maxs) continue;
return -1;
}
int lo = 0, hi = t;
for (int i = 0; i < t; i++)
v[i] = {w[i], s[i]};
sort(v, v + t,
[](item p, item q) {
return p.w < q.w ||
(p.w == q.w && p.s < q.s);
});
sort(x, x + a); sort(y, y + b);
while (lo < hi) {
priority_queue <int> pq;
int mi = (lo + hi) / 2, j = 0;
for (int i = 0; i < a; i++) {
while (j < t && v[j].w < x[i])
pq.push(v[j++].s);
int k = mi;
while (pq.size() && k) {
k--; pq.pop();
}
}
while (j < t) pq.push(v[j++].s);
for (int i = b - 1; ~i; i--) {
int k = mi;
while (pq.size() && k
&& pq.top() < y[i]) {
k--; pq.pop();
}
}
if (pq.size()) lo = mi + 1;
else hi = mi;
}
return hi;
}
# | 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... |