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;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<int> weak, small;
for (int i = 0; i < A; i++) {
weak.emplace_back(X[i]);
}
for (int i = 0; i < B; i++) {
small.emplace_back(Y[i]);
}
vector<pair<int, int>> arr(T);
for (int i = 0; i < T; i++) {
arr[i] = {W[i], S[i]};
}
sort(weak.begin(), weak.end());
sort(small.begin(), small.end());
auto works = [&](int time) {
vector<pair<int, int>> item = arr;
sort(item.begin(), item.end(), [&](auto a, auto b) {
return a.first > b.first;
});
for (auto to : weak) {
int left = time;
while(left && !item.empty() && item.back().first < to) {
--left;
item.pop_back();
}
}
return item.empty();
};
int lo = 0, hi = 1e9;
while(lo < hi) {
const int mid = lo + (hi - lo) / 2;
if (works(mid)) hi = mid;
else lo = mid + 1;
}
return (hi > 1e8 ? -1 : hi);
}
# | 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... |