This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#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[]) {
vector<pair<int, int>> toys(T);
for(int i = 0; i < T; i++)
toys[i] = {W[i], S[i]};
sort(toys.begin(), toys.end());
sort(X, X+A);
sort(Y, Y+B);
bool imp = 0;
for(auto p: toys)
if(p.first >= X[A-1] && p.second >= Y[B-1])
imp = 1;
if(imp)
return -1;
int lo = (T/(A+B))-1, hi = T;
if(lo < 0) lo = 0;
while(lo+1 < hi) {
int mid = (lo+hi)/2;
priority_queue<int> remaining;
int i = 0;
for(int a = 0; a < A; a++) {
while(i < T && toys[i].first < X[a]) {
remaining.push(toys[i++].second);
}
int j = mid;
while(!remaining.empty() && j--) {
remaining.pop();
}
}
while(i < T) {
remaining.push(toys[i++].second);
}
for(int b = B-1; b >= 0; b--) {
int j = mid;
while(!remaining.empty() && j--) {
if(remaining.top() >= Y[b])
break;
remaining.pop();
}
}
if(remaining.empty()) hi = mid;
else lo = mid;
}
return lo+1;
}
# | 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... |