CF2051A.Preparing for the Olympiad

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

Preparing for the Olympiad

Monocarp and Stereocarp are preparing for the Olympiad. There are nn days left until the Olympiad. On the ii-th day, if Monocarp plans to practice, he will solve aia_i problems. Similarly, if Stereocarp plans to practice on the same day, he will solve bib_i problems.

Monocarp can train on any day he wants. However, Stereocarp watches Monocarp and follows a different schedule: if Monocarp trained on day ii and i<ni \lt n, then Stereocarp will train on day (i+1)(i+1).

Monocarp wants to organize his training process in a way that the difference between the number of problems he solves and the number of problems Stereocarp solves is as large as possible. Formally, Monocarp wants to maximize the value of (ms)(m-s), where mm is the number of problems he solves, and ss is the number of problems Stereocarp solves. Help Monocarp determine the maximum possible difference in the number of solved problems between them.

Input

The first line contains a single integer tt (1t1031 \le t \le 10^3) — the number of test cases.

The first line of each test case contains a single integer nn (1n1001 \le n \le 100).

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1001 \le a_i \le 100).

The third line contains nn integers b1,b2,,bnb_1, b_2, \dots, b_n (1bi1001 \le b_i \le 100).

Output

For each test case, print a single integer — the maximum possible difference between the number of problems Monocarp solves and the number of problems Stereocarp solves.

Note

Let's analyze the example from the statement:

  • In the first test case, it is optimal for Monocarp to train both days; then Stereocarp will train on day 22.
  • In the second test case, it is optimal for Monocarp to train on the only day, and Stereocarp will not train at all.
  • In the third test case, it is optimal for Monocarp to train on the last day (and only on that day).
  • In the fourth test case, it is optimal for Monocarp to train on days 1,3,4,61, 3, 4, 6; then Stereocarp will train on days 2,4,52, 4, 5.

Samples

4
2
3 2
2 1
1
5
8
3
1 1 1
2 2 2
6
8 2 5 6 2 6
8 2 7 4 3 4
4
5
1
16

在线编程 IDE

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