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;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) (int)a.size()
#define s second
#define f first
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
bool can(int m, int a, int b, int t, int x[], int y[], vector<pii> s) {
int p = 0;
multiset<int> h;
for (int i = 0; i < a; i++) {
while (p < sz(s) && s[p].f < x[i]) {
h.insert(s[p].s);
p++;
}
int k = m;
while (sz(h) && k--)
h.erase(--h.end());
}
while (p < sz(s)) h.insert(s[p++].s);
for (int i = 0; i < b; i++) {
int k = m;
while (sz(h) && *h.begin() < y[i] && k--) {
h.erase(h.begin());
}
}
return h.empty();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<pii> s;
for (int i = 0; i < T; i++)
s.push_back({W[i], S[i]});
sort(s.begin(), s.end());
sort(X, X + A);
sort(Y, Y + B);
int l = 1, r = T;
while (l <= r) {
int m = (l + r) / 2;
if (can(m, A, B, T, X, Y, s)) r = m - 1;
else l = m + 1;
}
if (r == T) return -1;
return r + 1;
}
# | 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... |