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;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]) {
sort(X, X + a);
sort(Y, Y + b);
int n = t;
vector<array<int, 2>> A(n);
for (int i = 0; i < n; i++) {
A[i] = {S[i] , W[i]};
}
sort(all(A));
int l = 0, r = n, res = -1;
while (l <= r) {
int md = (l + r) / 2;
int ind = -1;
priority_queue<array<int, 2>> pq;
for (int i = 0; i < b; i++) {
while (ind + 1 < n && A[ind + 1][0] < Y[i]) {
ind++;
pq.push({A[ind][1], ind});
}
int temp = 0;
while (!pq.empty() && temp < md) {
pq.pop();
temp++;
}
}
while (ind + 1 < n) {
ind++;
pq.push({A[ind][1], ind});
}
for (int i = a - 1; i >= 0; i--) {
int temp = 0;
while (!pq.empty() && temp < md) {
array<int, 2> cur = pq.top();
if (cur[0] >= X[i]) {
break;
}
pq.pop();
temp++;
}
}
if (pq.empty()) {
res = md, r = md - 1;
}
else {
l = md + 1;
}
}
return res;
}
# | 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... |