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 <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[]) {
int ind[t];
for(int i = 0; i < t; i++)
ind[i] = i;
sort(ind, ind + t, [&](const int &a, const int &b){
return w[a] < w[b];
});
sort(x, x + a);
sort(y, y + b);
int l = 1, r = t, res = -1;
while (l <= r){
int mid = (l + r) >> 1;
priority_queue<int> pq;
int ptr = 0;
for(int i = 0; i < a; i++){
while (ptr < t && w[ind[ptr]] < x[i])
pq.push(s[ind[ptr++]]);
for(int j = 0; j < mid; j++)
if (!pq.empty())
pq.pop();
else
break;
}
while (ptr < t){
pq.push(s[ind[ptr++]]);
}
for(int i = b - 1; i >= 0; i--)
for(int j = 0; j < mid; j++)
if (!pq.empty() && pq.top() < y[i])
pq.pop();
else
break;
if (pq.empty()){
res = mid;
r = mid - 1;
} else {
l = mid + 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... |