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;
const int N = 1e6 + 3;
pair <pair <int,int>, int> arr[N];
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for (int i = 0; i < T; i++){
arr[i] = {{W[i],S[i]},i};
}
sort(arr,arr+T);
sort(X,X + A);
sort(Y,Y + B);
int l = 1, r = T,ans = -1;
while (l <= r){
int mid = (l + r) >> 1,L = 0;
priority_queue <int> st,st2;
for (int i = 0; i < A; i++){
while (L < T && arr[L].f.f < X[i]) {
st.push(arr[L].f.s);
++L;
}
int cnt = 0;
while (st.size() && cnt < mid){
st.pop();
++cnt;
}
}
while (L < T) st.push(arr[L++].f.s);
while (st.size()) st2.push(-st.top()),st.pop();
for (int i = 0; i < B; i++){
int cnt=0;
while (st2.size() && (-st2.top()) < Y[i] && cnt < mid){
st2.pop();
++cnt;
}
}
if (!st2.size()) {
ans = mid;
r = mid - 1;
}else{
l = mid + 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... |