# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091344 | LaMatematica14 | Robots (IOI13_robots) | C++17 | 0 ms | 0 KiB |
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;
bool cont(int A, int B, int T, int X[], int Y[], int W[], int S[], int tr) {
vector<array<int, 2>> ro(T+A);
for (int i = 0; i < T; i++) ro[i] = {W[i], S[i]};
for (int i = T; i < T+A; i++) ro[i] = {X[i-T], -1};
sort(ro.begin(), ro.end());
priority_queue<int> pq;
for (int i = 0; i < A+T; i++) {
if (ro[i][1] == -1) {
int c = 0;
while (!pq.empty() && c < tr) {
pq.pop(); c++;
}
}
else pq.push(ro[i][1]);
}
vector<array<int, 2>> rv(B);
for(int i = 0; i < B; i++) rv[i] = {Y[i], -1};
while (!pq.empty()) {
rv.push_back({pq.top(), 0}); pq.pop();
}
sort(rv.begin(), rv.end());
for (int i = 0; i < rv.size(); i++) {
if (rv[i][1] == -1) {
int c= 0;
while (!pq.empty() && c < tr) {
pq.pop(); c++;
}
}
else pq.push(rv[i][1]);
}
if (pq.empty()) return 1;
return 0;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
int l = 0, r = T+1;
while (l < r-1) {
int m = (l+r)/2;
if (cont(A, B, T, X, Y, W, S, m)) r = m;
else l = m;
}
if (r == T+1) return -1;
return r;
}