CF1972A.Contest Proposal

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Contest Proposal

A contest contains nn problems and the difficulty of the ii-th problem is expected to be at most bib_i. There are already nn problem proposals and the difficulty of the ii-th problem is aia_i. Initially, both a1,a2,…,ana_1, a_2, \ldots, a_n and b1,b2,…,bnb_1, b_2, \ldots, b_n are sorted in non-decreasing order.

Some of the problems may be more difficult than expected, so the writers must propose more problems. When a new problem with difficulty ww is proposed, the most difficult problem will be deleted from the contest, and the problems will be sorted in a way that the difficulties are non-decreasing.

In other words, in each operation, you choose an integer ww, insert it into the array aa, sort array aa in non-decreasing order, and remove the last element from it.

Find the minimum number of new problems to make ai≤bia_i\le b_i for all ii.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1001\le t\le 100). The description of the test cases follows.

The first line of each test case contains only one positive integer nn (1≤n≤1001 \leq n \leq 100), representing the number of problems.

The second line of each test case contains an array aa of length nn (1≤a1≤a2≤⋯≤an≤1091\le a_1\le a_2\le\cdots\le a_n\le 10^9).

The third line of each test case contains an array bb of length nn (1≤b1≤b2≤⋯≤bn≤1091\le b_1\le b_2\le\cdots\le b_n\le 10^9).

Output

For each test case, print an integer as your answer in a new line.

Note

In the first test case:

  • Propose a problem with difficulty w=800w=800 and aa becomes [800,1000,1400,2000,2000,2200][800,1000,1400,2000,2000,2200].
  • Propose a problem with difficulty w=1800w=1800 and aa becomes [800,1000,1400,1800,2000,2000][800,1000,1400,1800,2000,2000].

It can be proved that it's impossible to reach the goal by proposing fewer new problems.

In the second test case:

  • Propose a problem with difficulty w=1w=1 and aa becomes [1,4,5,6,7,8][1,4,5,6,7,8].
  • Propose a problem with difficulty w=2w=2 and aa becomes [1,2,4,5,6,7][1,2,4,5,6,7].
  • Propose a problem with difficulty w=3w=3 and aa becomes [1,2,3,4,5,6][1,2,3,4,5,6].

It can be proved that it's impossible to reach the goal by proposing fewer new problems.

Samples

2
6
1000 1400 2000 2000 2200 2700
800 1200 1500 1800 2200 3000
6
4 5 6 7 8 9
1 2 3 4 5 6
2
3

在线编程 IDE

建议全屏模式获得最佳体验