## NOI '19 P3 - Sequence

View as PDF

Points: 25 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem type

Given two positive integer sequences and of length , you must find two sequences and of length satisfying the following conditions:

1. .
2. .
3. .

Subject to these conditions, maximize .

#### Input Specification

The first line contains an integer , indicating the number of testcases.

For each testcase:

The first line contains three integers .

The second line contains integers, indicating .

The third line contains integers, indicating .

#### Constraints

For all test cases, .

Test Case
1~3
4~5
6~7
8~10
11~16
17~21
22~25

#### Output Specification

Output one integer on one line, the answer.

#### Sample Input 1

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

#### Sample Output 1

14
12
27
45
62