이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
int const kT = 1000005;
bool used[kT];
int perm[kT];
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X, X + A);
sort(Y, Y + B);
iota(perm, perm + T, 0);
auto check = [&](int t) -> bool {
memset(used, 0, sizeof used);
sort(perm, perm + T, [&](int a, int b) {
return make_tuple(W[a], S[a]) < make_tuple(W[b], S[b]);
});
priority_queue<pair<int, int>> pq;
int p = 0;
for (int i = 0; i < A; ++i) {
while (p < T && W[perm[p]] < X[i]) {
pq.emplace(S[perm[p]], perm[p]);
++p;
}
for (int j = 0; j < t && !pq.empty(); ++j) {
auto [s, idx] = pq.top();
used[idx] = true;
pq.pop();
}
}
sort(perm, perm + T, [&](int a, int b) {
return make_tuple(S[a], W[a]) < make_tuple(S[b], W[b]);
});
pq = priority_queue<pair<int, int>>();
p = 0;
for (int i = 0; i < B; ++i) {
while (p < T && S[perm[p]] < Y[i]) {
if (!used[perm[p]]) {
pq.emplace(W[perm[p]], perm[p]);
}
++p;
}
for (int j = 0; j < t && !pq.empty(); ++j) {
auto [w, idx] = pq.top();
used[idx] = true;
pq.pop();
}
}
return all_of(used, used + T, [](bool b) { return b; });
};
int lo = 0, hi = T + 1;
while (lo < hi) {
int mid = lo + (hi - lo) / 2;
if (check(mid)) {
hi = mid;
} else lo = mid + 1;
}
if (lo > T) return -1;
else 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... |