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 INF = 1e9 + 5;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X, X+A);
sort(Y, Y+B);
vector<pair<int, int>> a(T);
for(int i = 0; i < T; i++) {
a[i] = {W[i], S[i]};
}
sort(a.begin(), a.end());
int l = 0, r = INF, ans = INF;
while(l <= r) {
int mid = (l + r) / 2;
priority_queue<int> q;
int idx = 0;
for(int i = 0; i < A; i++) {
while(idx < T && X[i] > a[idx].first) {
q.push(a[idx].second);
idx++;
}
for(int j = 0; j < mid && !q.empty(); j++) {
q.pop();
}
}
while(idx < T) {
q.push(a[idx].second);
idx++;
}
for(int i = B-1; i >= 0; i--) {
for(int j = 0; j < mid && !q.empty(); j++) {
if (q.top() < Y[i]) {
q.pop();
} else {
break;
}
}
}
if (q.empty()) {
ans = mid;
r = mid - 1;
} else {
l = mid + 1;
}
}
if (ans == INF) return -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... |