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;
using P = pair<int, int>;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
int ng = 0, ok = T + 1;
vector<P> v;
for (int i = 0; i < T; i++) {
v.push_back(P(W[i], S[i]));
}
sort(v.begin(), v.end());
sort(X, X + A);
sort(Y, Y + B);
vector<int> f(T);
while (ok - ng > 1) {
int mid = (ok + ng) / 2;
int id = 0;
fill(f.begin(), f.end(), 0);
priority_queue<P> q;
for (int i = 0; i < A; i++) {
while (id < T && v[id].first < X[i]) {
q.push(P(v[id].second, id));
id++;
}
int c = mid;
while (c > 0 && !q.empty()) {
int to = q.top().second;
q.pop();
f[to] = 1;
--c;
}
}
priority_queue<int, vector<int>, greater<int>> q2;
while (!q.empty()) {
q2.push(q.top().first);
q.pop();
}
for (; id < T; id++) {
q2.push(v[id].second);
}
for (int i = 0; i < B; i++) {
int c = mid;
while (c > 0 && !q2.empty()) {
if (q2.top() >= Y[i]) {
break;
}
q2.pop();
--c;
}
}
if (q2.empty()) {
ok = mid;
} else {
ng = mid;
}
}
if (ok == T + 1) {
return -1;
}
return ok;
}
# | 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... |