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>
using namespace std;
vector<pair<int, int>> toy;
vector<int> w, s;
int ss, ww, tt;
priority_queue<int> in;
bool pos(int t){
in = priority_queue<int>();
int now = 0;
for(int i = 0; i < ww; i++){
while(now < tt && toy[now].first < w[i]){
in.push(toy[now].second);
now++;
}
for(int j = 0; j < t; j++){
if(in.empty()) break;
in.pop();
}
}
for(; now < tt; now++)
in.push(toy[now].second);
if(in.empty())return 1;
for(int i = ss - 1; i >= 0; i--){
if(in.top() >= s[i]) return 0;
for(int j = 0; j < t; j++){
in.pop();
if(in.empty()) return 1;
}
}
if(in.empty()) return 1;
return 0;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for(int i = 0; i < T; i++)
toy.push_back({W[i], S[i]});
for(int i = 0; i < A; i++)
w.push_back(X[i]);
for(int i = 0; i < B; i++)
s.push_back(Y[i]);
ss = B;
ww = A;
tt = T;
sort(toy.begin(), toy.end());
sort(w.begin(), w.end());
sort(s.begin(), s.end());
int l = 0, r = 1000001;
int m;
while(l != r){
m = (l + r) >> 1;
if(pos(m)) r = m;
else l = m + 1;
}
if(r == 1000001) return -1;
return r;
}
# | 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... |