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 <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]) {
vector<int> x, y;
for (int i=0; i<a; i++) x.push_back(X[i]);
for (int i=0; i<b; i++) y.push_back(Y[i]);
sort(x.begin(), x.end());
sort(y.begin(), y.end());
vector<pair<int, int> > v;
for (int i=0; i<t; i++) {
v.emplace_back(W[i], S[i]);
if ((x.empty() || W[i]>=x.back()) && (y.empty() || S[i]>=y.back())) return -1;
}
sort(v.begin(), v.end());
reverse(y.begin(), y.end());
int low=1, high=t, mid;
while (low != high) {
mid = (low+high) >> 1;
priority_queue<int> pq;
int cur = 0;
for (int i : x) {
while (cur<t && v[cur].first<i) pq.push(v[cur++].second);
int z = min((int)pq.size(), mid);
for (int i=0; i<z; i++) pq.pop();
}
for (; cur<t; cur++) pq.push(v[cur].second);
for (int i : y) {
int z = 0;
while (z++<mid && !pq.empty() && pq.top()<i) pq.pop();
}
if (pq.empty()) high = mid;
else low = mid+1;
}
return low;
}
# | 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... |