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>
using namespace std;
const int N = 1000005;
int P[N];
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for (int i = 0; i < T; ++i) P[i] = i;
sort(X, X + A);
sort(Y, Y + B);
sort(P, P + T, [&] (int x, int y) {
return W[x] < W[y];
});
int l = 1, r = T;
while (l < r) {
int mid = (l + r) >> 1;
int ptr = 0;
priority_queue<int> pq;
for (int i = 0; i < A; ++i) {
while (ptr < T && W[P[ptr]] < X[i]) pq.push(S[P[ptr++]]);
int cur = mid;
while (cur && pq.size()) pq.pop(), cur--;
}
while (ptr < T) pq.push(S[P[ptr++]]);
for (int i = B - 1; i >= 0; --i) {
int cur = mid;
while (cur && pq.size() && pq.top() < Y[i]) {
pq.pop(), cur--;
}
}
if (pq.size()) l = mid + 1;
else r = mid;
}
int ptr = 0;
priority_queue<int> pq;
for (int i = 0; i < A; ++i) {
while (ptr < T && W[P[ptr]] < X[i]) pq.push(S[P[ptr++]]);
int cur = l;
while (cur && pq.size()) pq.pop(), cur--;
}
while (ptr < T) pq.push(S[P[ptr++]]);
for (int i = B - 1; i >= 0; --i) {
int cur = l;
while (cur && pq.size() && pq.top() < Y[i]) {
pq.pop(), cur--;
}
}
if (pq.size() == 0) return l;
return -1;
}
# | 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... |