이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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(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 + 1;
while (low < high){
int mid = (low + high) / 2;
check(mid) ? high = mid : low = mid + 1;
}
return (high == T + 1) ? -1 : high;
}
# | 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... |