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 a, b, t, *x, *y, *w, *s, cnt;
set <int> se;
pair <int, int> p[1000005];
bool can(int k){
se.clear();
int j = 0;
for (int i = 0;i < a;i++){
while (j < t && p[j].first < x[i])
se.insert(s[p[j++].second]);
cnt = k;
while (cnt-- && !se.empty()) {
auto it = se.end();
it--;
se.erase(it);
}
}
for (;j < t;j++) se.insert(s[p[j].second]);
j = 0;
cnt = k;
// cout << k << endl;
// for (auto a : se) cout << a << ' ';
// cout << endl;
for (auto a : se){
while (j < b && (!cnt || a >= y[j])){
j++;
cnt = k;
}
if (j == b) return 0;
cnt--;
}
return 1;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
a = A, b = B, t = T, x = X, y = Y, w = W, s = S;
sort(x, x + a);
sort(y, y + b);
for (int i = 0;i < t;i++){
if (w[i] >= x[a - 1] && s[i] >= y[b - 1])
return -1;
p[i].first = w[i];
p[i].second = i;
}
sort(p, p + t);
// for (int i = 0;i < t;i++)
// cout << p[i].first << ' '<< s[p[i].second] << endl;
// for (int i = 0;i < a;i++) cout << x[i] << endl;
// cout << endl;
// for (int i = 0;i < b;i++) cout << y[i] << ' ';
// cout << endl;
int l = 1, r = t, mid;
while (l != r){
mid = (l + r) / 2;
if (can(mid)) r = mid;
else l = mid + 1;
}
return l + 1;
}
# | 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... |