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;
const int nx=1e6+5;
int l=1, r=nx, d[nx];
vector<pair<int, int>> w, s;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X, X+A);
sort(Y, Y+B);
w.push_back({INT_MAX, T});
s.push_back({INT_MAX, T});
for (int i=0; i<T; i++) w.push_back({W[i], i}), s.push_back({S[i], i});
sort(w.begin(), w.end());
sort(s.begin(), s.end());
while (l<r)
{
int md=(l+r)/2, p=0, cnt=0;
priority_queue<pair<int, int>> pq;
for (int i=0; i<T; i++) d[i]=0;
for (int i=0; i<A; i++)
{
while (w[p].first<X[i]) pq.push({S[w[p].second], w[p].second}), p++;
int tmp=md;
while (tmp>0&&!pq.empty()) cnt++, d[pq.top().second]=1, pq.pop(), tmp--;
}
while (!pq.empty()) pq.pop();
p=0;
for (int i=0; i<B; i++)
{
while (s[p].first<Y[i]||d[s[p].second])
{
if (d[s[p].second]) p++;
else pq.push({W[s[p].second], s[p].second}), p++;
}
int tmp=md;
while (tmp>0&&!pq.empty()) cnt++, d[pq.top().second]=1, pq.pop(), tmp--;
}
if (cnt==T) r=md;
else l=md+1;
}
return (l==nx)?-1:l;
}
# | 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... |