#include <bits/stdc++.h>
#include "robots.h"
using namespace std;
int A, B, T;
int putaway(int a, int b, int t, int *X, int *Y, int *W, int *S)
{
A = a;
B = b;
T = t;
sort(X, X + A);
sort(Y, Y + B);
for(int i = 0; i < T; i++) if((!A || (W[i] >= X[A - 1])) && (!B || (S[i] >= Y[B - 1]))) return -1;
if((T == 2) && ((A + B) == 2))
{
if((A == 2) && (min(W[0], W[1]) < X[0]) && (max(W[0], W[1]) < X[1])) return 1;
if((B == 2) && (min(S[0], S[1]) < Y[0]) && (max(S[0], S[1]) < Y[1])) return 1;
if((A == 1) && (B == 1) && (((W[0] < X[0]) && (S[1] < Y[0])) || ((W[1] < X[0]) && (S[0] < Y[0])))) return 1;
return 2;
}
if(!B)
{
sort(W, W + T);
int ret, l = 1, r = T, s;
auto OK = [&]()
{
for(int i = T - 1, j = A - 1, k = 0; i >= 0; i--, k++)
{
if(k == s) {j--; k = 0;}
if((j < 0) || (W[i] >= X[j])) return false;
}
return true;
};
while(l <= r)
{
s = (l + r) >> 1;
if(!OK()) l = s + 1;
else {r = s - 1; ret = s;}
}
return ret;
}
return -1;
}
//int main()
//{
// int a, b, t;
// cin >> a >> b >> t;
// int x[a], y[b], w[t], s[t];
// cout << putaway(a, b, t, x, y, w, s) << '\n';
// return 0;
//}
# | 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... |