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>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second
using namespace std;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
int a = A, b = B, t = T;
vector<int> x, y;
vector<pair<int, int> > nums;
for (int i = 0; i < a; i++)
x.pb(X[i]);
for (int i = 0; i < b; i++)
y.pb(Y[i]);
for (int i = 0; i < t; i++)
nums.pb({W[i], S[i]});
sort(x.begin(), x.end());
sort(y.begin(), y.end());
sort(nums.begin(), nums.end());
for (int i = 0; i < t; i++) {
if ((a == 0 || nums[i].ff >= x.back()) && (b == 0 || nums[i].ss >= y.back()))
return -1;
}
int l = 0, r = T;
while (l < r) {
int mid = (l + r) / 2, now = 0;
priority_queue<int> del;
for (int i = 0; i < a; i++) {
while (now < t && nums[now].ff < x[i])
del.push(nums[now].ss), now++;
for (int j = 0; j < mid; j++) {
if (del.empty()) break;
del.pop();
}
}
while (now < t) del.push(nums[now].ss), now++;
for (int i = b-1; i >= 0; i--) {
for (int j = 0; j < mid; j++) {
if (del.empty() || del.top() >= y[i]) break;
del.pop();
}
}
if (del.empty())
r = mid;
else
l = mid+1;
}
return l;
}
# | 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... |