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[]){
pair<int, int> toys[T];
for (int i = 0; i < T; i++) toys[i] = {W[i], S[i]};
sort(X, X + A); sort(Y, Y + B); sort(toys, toys + T);
auto check = [&](int mid){
priority_queue<int> pq; int pt = 0;
for (int i = 0; i < A; i++){
for (; pt < T and toys[pt].first < X[i]; pt++) pq.push(toys[pt].second);
for (int j = 0; j < mid and !pq.empty(); j++) pq.pop();
}
for (; pt < T; pt++) pq.push(toys[pt].second);
for (int i = B - 1; i >= 0; i--){
for (int j = 0; j < mid and !pq.empty() and pq.top() < Y[i]; j++) pq.pop();
}
return pq.empty();
};
int low = 1, high = T;
while (low < high){
int mid = (low + high) / 2;
check(mid) ? high = mid : low = mid + 1;
}
return check(high) ? high : -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... |