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 <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dl double
#define st first
#define nd second
#define II pair <int, int>
#include "robots.h"
using namespace std;
int a, b, t;
vector <int> x, y, posx, posy;
vector <II> e;
int check(int lim) {
priority_queue <int> q;
int pos = 0;
for (int i = 1; i <= a; i ++) {
while (pos < t && e[pos].st < x[i]) {
q.push(e[pos].nd);
pos ++;
}
for (int cnt = 0; cnt < lim; cnt ++) {
if (q.empty())
break;
q.pop();
}
}
while (pos < t) {
q.push(e[pos].nd);
pos ++;
}
for (int i = b; i > 0; i --)
for (int cnt = 0; cnt < lim; cnt ++) {
if (q.empty())
break;
if (q.top() < y[i])
q.pop();
else
return 0;
}
return q.empty();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
a = A; b = B; t = T;
x.assign(a + 1, 0);
for (int i = 1; i <= a; i ++)
x[i] = X[i - 1];
y.assign(b + 1, 0);
for (int i = 1; i <= b; i ++)
y[i] = Y[i - 1];
for (int i = 0; i < T; i ++)
e.push_back({W[i], S[i]});
sort(x.begin() + 1, x.end());
sort(y.begin() + 1, y.end());
sort(e.begin(), e.end());
int lo = 1, hi = t + 1;
while (lo < hi) {
int mid = (lo + hi) / 2;
if (check(mid))
hi = mid;
else
lo = mid + 1;
}
if (lo == t + 1)
lo = -1;
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... |