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>
#define pii pair<int, int>
using namespace std;
int ans = -1;
pii toy[1000005];
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for(int i = 0; i < T; i++) {
toy[i] = {W[i], S[i]};
}
sort(toy, toy + T);
sort(X, X + A);
sort(Y, Y + B);
int l = 1, r = T, mid;
int p = 0;
toy[T] = {INT_MAX, 0};
while(l <= r) {
priority_queue<int, vector<int>> pq;
mid = (l + r) >> 1;
p = 0;
for(int i = 0; i < A; i++) {
while(toy[p].first < X[i]) pq.emplace(toy[p++].second);
for(int k = 0; k < mid && !pq.empty(); k++) pq.pop();
}
while(p < T) pq.emplace(toy[p++].second);
for(int i = B - 1; i >= 0; i--) {
for(int k = 0; k < mid && !pq.empty(); k++) {
if(pq.top() >= Y[i]) goto STOP;
pq.pop();
}
}
STOP:
if(pq.empty()) {
ans = mid;
r = mid - 1;
}else {
l = mid + 1;
}
}
return ans;
}
# | 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... |