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 f first
#define s second
using namespace std;
int putaway(int A, int B, int N, int X[], int Y[], int W[], int S[]) {
vector<pair<int,int>> p(N);
for(int i = 0; i < N; i++) {
p[i] = {W[i], S[i]};
}
sort(p.begin(), p.end());
// for(int i = 0; i < N; i++) cout << p[i].f << " " << p[i].s << "\n";
sort(X, X + A); sort(Y, Y + B);
int l = 1, r = N, ans = N + 1;
while(l <= r) {
int mid = (l + r) / 2;
priority_queue<int, vector<int>, less<int>> s;
{
int L = -1;
for(int i = 0; i < A; i++) {
while(L + 1 < N && p[L + 1].f < X[i]) ++L, s.push(p[L].s);
for(int j = 1; j <= mid; j++) {
if(!s.size()) break;
s.pop();
}
}
while(L + 1 < N) s.push(p[L + 1].s),++L;
for(int i = B - 1; i >= 0; i--) {
for(int j = mid; j >= 1; j--) {
if(!s.size() || s.top() >= Y[i]) break;
s.pop();
}
}
}
if(s.size()) l = mid + 1;
else r = mid - 1, ans = mid;
}
if(ans > N ) ans = -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... |