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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> sus;
priority_queue<ll, vector<ll>, greater<ll>> sus2;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X,X+A);
sort(Y,Y+B);
FOR(i,0,T){
if (W[i] >= X[A-1] && S[i] >= Y[B-1]){
return -1;
}
}
FOR(i,0,T){
W[i] = lower_bound(X,X+A, W[i]+1)-X;
}
const auto check = [&](int k) -> bool{
while (sus.size()) sus.pop();
while (sus2.size()) sus2.pop();
FOR(i,0,T){
sus.push(make_pair(W[i], -S[i]));
}
FOR(i,0,A){
ll cnt = 0;
while (sus.size()!=0){
if (cnt==k) break;
ll temp = sus.top().first;
if (temp > i) break;
cnt++;
sus.pop();
}
}
while (sus.size()!=0){
ll temp = sus.top().second;
sus.pop();
sus2.push(-temp);
}
FOR(i,0,B){
ll cnt = 0;
while (sus2.size()!=0){
if (cnt==k) break;
ll temp = sus2.top();
if (temp >= Y[i]) break;
cnt++;
sus2.pop();
}
}
if (sus2.size()) return 0;
else return 1;
};
ll lo = 0;
ll hi = T+1;
while (lo<hi){
ll mid = lo + (hi - lo) / 2;
if (check(mid)) hi = mid;
else lo = mid + 1;
}
return lo;
}
# | 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... |