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;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X, X+A);
sort(Y, Y+B);
pair<int, int> p[T];
for(int i = 0; i < T; i++) {
p[i].first = W[i];
p[i].second = S[i];
}
sort(p, p+T);
int l = 0, r = T+1, m;
while(l < r) {
m = (l+r)/2;
priority_queue<int> pq;
int idx = 0, ok = 1;
for(int i = 0; i < A; i++) {
while(idx < T && p[idx].first < X[i]) {
pq.push(p[idx++].second);
}
for(int j = 0; j < m && pq.size(); j++) pq.pop();
}
while(idx < T) pq.push(p[idx++].second);
for(int i = B-1; i >= 0; i--) {
if(pq.size() && pq.top() >= Y[i]) {
ok = 0;
goto ed;
}
for(int j = 0; j < m && pq.size(); j++) pq.pop();
}
ed:;
if(ok) r = m;
else l = m+1;
}
if(l == T+1) return -1;
else return l;
}
# | 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... |