#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include "robots.h"
using namespace std;
int a, b, t, x[50005], y[50005], w[1000005], s[1000005];
bool check(int mid)
{
int i = t - 1;
for(int j = a - 1; j >= 0; j--)
{
int cnt = 0;
while(i >= 0 && cnt < mid && w[i] < x[j])
{
i--;
cnt++;
}
}
return i < 0;
}
int bin_search()
{
int l = 1, r = t;
while(l <= r)
{
int mid = (l+r)/2;
if(check(mid))r = mid-1;
else l = mid+1;
}
if(l > t)return -1;
return l;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
if(T == 2 && A+B == 2)
{
if(A == 1 && B == 1)
{
if(W[0] < X[0] && S[1] < Y[0])return 1;
if(W[1] < X[0] && S[0] < Y[0])return 1;
if(W[0] < X[0] && W[1] < X[0])return 2;
if(S[0] < Y[0] && S[1] < Y[0])return 2;
return -1;
}
if(A == 2)
{
if(W[0] < X[0] && W[1] < X[1])return 1;
if(W[1] < X[0] && W[0] < X[1])return 1;
if(W[0] < X[0] && W[1] < X[0])return 2;
if(W[0] < X[1] && W[1] < X[1])return 2;
return -1;
}
if(B == 2)
{
if(S[0] < Y[0] && S[1] < Y[1])return 1;
if(S[1] < Y[0] && S[0] < Y[1])return 1;
if(S[0] < Y[0] && S[1] < Y[0])return 2;
if(S[0] < Y[1] && S[1] < Y[1])return 2;
}
}
a = A;
b = B;
t = T;
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 < t; i++)
{
w[i] = W[i];
s[i] = S[i];
}
sort(w, w+t);
sort(x, x+a);
return bin_search();
}