CF2131A.Lever

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

Lever

In Divergent Universe, The Lever iterates itself given two arrays aa and bb of length nn. In each iteration, The Lever will do the following:

  1. Choose a random index ii such that ai>bia_i \gt b_i. Then, decrease aia_i by 11. If there does not exist such ii, ignore this step.
  2. Choose a random index ii such that ai<bia_i \lt b_i. Then, increase aia_i by 11. If there does not exist such ii, ignore this step.

After each iteration, the Lever will check if step 11 is ignored, and if so, it will end its iteration.

You're given the two arrays. Find the number of iterations that the Lever does. It can be shown this number is fixed over all possibilities of random indices that The Lever can choose for each step.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains one integer nn (1n101 \le n \le 10).

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai101 \le a_i \le 10).

The third line of each test case contains nn integers b1,b2,,bnb_1, b_2, \dots, b_n (1bi101 \le b_i \le 10).

Output

For each test case, output one integer — the number of iterations that the Lever does.

Note

In the first sample case:

In the first iteration, the Lever decreases a1a_1 by 11 and increases a2a_2 by 11, and aa becomes [6,4][6,4].

In the second iteration, the Lever decreases a1a_1 by 11 and increases a2a_2 by 11, and aa becomes [5,5][5,5].

In the third iteration, the Lever increases a2a_2 by 11, and aa becomes [5,6][5,6]. Since it fails to decrease an element, its iteration ends. Therefore, the answer is 33.

In the second sample case, the Lever does nothing in its first iteration, and thus it does only one iteration.

Samples

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

在线编程 IDE

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