C - Sushi Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

寿司の材料として、N 個のシャリと M 個のネタがあります。

i 番目のシャリの重さは A_ij 番目のネタの重さは B_j です。

あなたは、シャリとネタを組み合わせることで寿司を作ろうとしています。

寿司を 1 つ作るためには、1 つのシャリと 1 つのネタを組み合わせる必要があります。ただし、ネタの重さはシャリの重さの 2 倍以下でなければなりません。また、1 つのシャリやネタを複数の寿司に使うことはできません。

作ることのできる寿司の個数の最大値を求めてください。

制約

  • 1 \leq N, M \leq 2 \times 10^5
  • 1 \leq A_i, B_j \leq 10^9
  • 入力される値はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

N M
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_M

出力

答えを出力せよ。


入力例 1

4 5
4 2 1 8
14 9 3 2 9

出力例 1

3

1 番目のシャリと 3 番目のネタ、2 番目のシャリと 4 番目のネタ、4 番目のシャリと 1 番目のネタを組み合わせるなどの方法で 3 つの寿司を作ることができます。4 つ以上の寿司を作ることはできないため、3 を出力します。


入力例 2

3 3
5 5 3
11 1000 1000

出力例 2

0

入力例 3

8 7
2 3 4 4 4 3 2 3
8 5 5 9 9 7 1

出力例 3

5

Score : 300 points

Problem Statement

There are N pieces of shari (vinegared rice) and M pieces of neta (toppings) as ingredients for sushi.

The weight of the i-th shari is A_i, and the weight of the j-th neta is B_j.

You will make sushi by combining shari and neta.

To make one piece of sushi, you need to combine one shari with one neta. Here, the weight of the neta must be at most twice the weight of the shari. Also, the same shari or neta cannot be used in multiple pieces of sushi.

Find the maximum number of sushi that can be made.

Constraints

  • 1 \leq N, M \leq 2 \times 10^5
  • 1 \leq A_i, B_j \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N M
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_M

Output

Output the answer.


Sample Input 1

4 5
4 2 1 8
14 9 3 2 9

Sample Output 1

3

By combining the 1st shari with the 3rd neta, the 2nd shari with the 4th neta, and the 4th shari with the 1st neta, for example, you can make three pieces of sushi. It is impossible to make four or more pieces of sushi, so output 3.


Sample Input 2

3 3
5 5 3
11 1000 1000

Sample Output 2

0

Sample Input 3

8 7
2 3 4 4 4 3 2 3
8 5 5 9 9 7 1

Sample Output 3

5