Codeforces Round 905 (Div. 1)
A1
Dances (Easy version)
Codeforces
未评级
原题
←A2 →
翻译中…

This is the easy version of the problem. The only difference is that in this version $m = 1$.

翻译中…

You are given two arrays of integers $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$. Before applying any operations, you can reorder the elements of each array as you wish. Then, in one operation, you will perform both of the following actions, if the arrays are not empty:

翻译中…
  • Choose any element from array $a$ and remove it (all remaining elements are shifted to a new array $a$),
  • Choose any element from array $b$ and remove it (all remaining elements are shifted to a new array $b$).
翻译中…

Let $k$ be the final size of both arrays. You need to find the minimum number of operations required to satisfy $a_i \lt b_i$ for all $1 \leq i \leq k$.

翻译中…

This problem was too easy, so the problem author decided to make it more challenging. You are also given a positive integer $m$. Now, you need to find the sum of answers to the problem for $m$ pairs of arrays $(c[i], b)$, where $1 \leq i \leq m$. Array $c[i]$ is obtained from $a$ as follows:

翻译中…
  • $c[i]_1 = i$,
  • $c[i]_j = a_j$, for $2 \leq j \leq n$.
翻译中…

Input

翻译中…

Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) - the number of sets of input data. This is followed by their description.

翻译中…

The first line of each test case contains two integers $n$ and $m$ ($2 \leq n \leq 10^5$, $m = 1$) - the size of arrays $a$ and $b$ and the constraints on the value of element $a_1$.

翻译中…

The second line of each test case contains $n - 1$ integers $a_2, \ldots, a_n$ ($1 \leq a_i \leq 10^9$).

翻译中…

The third line of each test case contains $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \leq b_i \leq 10^9$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.

翻译中…

Output

翻译中…

For each test case, output the total number of minimum operations for all pairs of arrays $(c_i, b)$.

翻译中…

Note

翻译中…

In the first test case for the pair of arrays $([1, 1], [3, 2])$, the answer is $0$. No operations or reordering of elements are needed.

翻译中…

样例

Input #1
4
2 1
1
3 2
4 1
5 1 5
3 8 3 3
8 1
4 3 3 2 2 1 1
1 1 1 1 3 3 3 3
9 1
9 2 8 3 7 4 6 5
1 2 3 2 1 4 5 6 5
Output #1
0
1
4
4
InputCopy OutputCopy
题目信息
题号
1887A1
时间限制
3 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。