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 <bits/stdc++.h>
using namespace std;
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); it++)
typedef long long ll;
typedef pair < int, int > ii;
const int inf = 1e9 + 333;
const ll linf = 1e18 + inf;
#include "robots.h"
const int N = 1e6 + 5;
int n;
int A, B;
int X[N], Y[N];
ii a[N];
vector < int > v;
bool f(int x) {
int ptr = 0;
for(int i = 0; i < B; i++) {
int rem = x;
while(ptr < n and rem and a[ptr].second <= Y[i]) {
ptr++;
rem--;
}
if(ptr == n)
return 1;
}
v.clear();
for(int i = ptr; i < n; i++)
v.push_back(a[i].first);
sort(v.begin(), v.end());
ptr = 0;
for(int i = 0; i < A; i++) {
int rem = x;
while(ptr < v.size() and rem and v[ptr] <= X[i]) {
ptr++;
rem--;
}
if(ptr == v.size())
return 1;
}
return 0;
}
int putaway(int A, int B, int n, int X[], int Y[], int W[], int S[]) {
:: n = n;
:: A = A;
:: B = B;
sort(X, X + A);
sort(Y, Y + B);
for(int i = 0; i < A; i++)
:: X[i] = X[i];
for(int i = 0; i < B; i++)
:: Y[i] = Y[i];
for(int i = 0; i < n; i++) {
a[i] = ii(W[i], S[i]);
}
sort(a, a + n);
for(int i = 0; i < n; i++)
swap(a[i].first, a[i].second);
if(!f(n))
return -1;
int l = 1, r = n;
while(l < r) {
int m = l + r >> 1;
if(f(m))
r = m;
else
l = m + 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... |