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;
using pii = pair<int, int>;
int putaway(int A, int B, int T, int X1[], int Y1[], int W1[], int S1[]) {
vector<int> X, Y;
vector<array<int, 3> > v;
for(int i=0; i<A; i++) X.push_back(X1[i]);
for(int i=0; i<B; i++) Y.push_back(Y1[i]);
for(int i=0; i<T; i++) v.push_back({ W1[i], S1[i], 0 });
sort(X.begin(), X.end());
sort(Y.begin(), Y.end());
int l=1, r=T, ans=-1;
while(l <= r) {
int mid = (l + r) / 2;
bool ok = 1;
for(int i=0; i<T; i++) v[i][2] = 0;
sort(v.begin(), v.end());
priority_queue<pii> pq;
int j = 0;
for(int i=0; i<A; i++) {
while(j < T && v[j][0] < X[i]) pq.push({ v[j][1], j }), j++;
for(int k=0; k<mid&&!pq.empty(); k++) {
v[pq.top().second][2] = 1;
pq.pop();
}
}
vector<int> vec;
sort(v.begin(), v.end(), [&](array<int, 3> a, array<int, 3> b) {
return a[1] < b[1];
});
j = 0;
for(int i=0; i<B; i++) {
while(j < T && v[j][1] < Y[i]) {
if(v[j][2] == 0) vec.push_back(j);
j++;
}
for(int k=0; k<mid&&!vec.empty(); k++) {
v[vec.back()][2] = 1;
vec.pop_back();
}
}
for(int i=0; i<T; i++) if(v[i][2] == 0) ok = 0;
if(ok) ans = mid, r = mid - 1;
else l = mid + 1;
}
return ans;
}
# | 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... |