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;
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<int> o(T, 0);
iota(o.begin(), o.end(), 0);
sort(o.begin(), o.end(), [&](const int &a, const int &b)
{
return W[a] < W[b];
});
int l = 1, r = T + 1;
priority_queue<int> ms;
while (l < r)
{
while (!ms.empty()) ms.pop();
int mid = (l + r) >> 1;
int j = 0;
for (int i = 0; i < A; i++)
{
while (j < T && W[o[j]] < X[i]) ms.push(S[o[j]]), j++;
int c = mid;
while (c-- && !ms.empty()) ms.pop();
}
while (j < T) ms.push(S[o[j]]), j++;
for (int i = B - 1; i >= 0; i--)
{
int c = mid;
while (c-- && !ms.empty() && ms.top() < Y[i]) ms.pop();
}
if (ms.empty()) r = mid;
else l = mid + 1;
}
return (l == T + 1 ? -1 : l);
}
# | 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... |