# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377283 | gustason | Robots (IOI13_robots) | C++14 | 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;
const int INF = 1e9 + 5;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X, X+A);
sort(Y, Y+B);
vector<pair<int, int>> a(T);
for(int i = 0; i < n; i++) {
a[i] = {W[i], S[i]};
}
sort(a.begin(), a.end());
int l = 0, r = INF, ans = 0;
while(l <= r) {
int mid = (l + r) / 2;
priority_queue<int> q;
int idx = 0;
for(int i = 0; i < A; i++) {
while(idx < T && X[i] > v[idx].first) {
q.push(v[idx].second);
idx++;
}
for(int j = 0; j < mid && !q.empty(); j++) {
q.pop();
}
}
while(idx < T) {
q.push(v[idx].second);
idx++;
}
for(int i = B-1; i >= 0; i--) {
for(int j = 0; j < mid && !q.empty(); j++) {
if (q.top() < Y[i]) {
q.pop();
} else {
break;
}
}
}
if (q.empty()) {
ans = mid;
r = mid - 1;
} else {
l = mid + 1;
}
}
if (ans == INF) return -1;
return ans;
}