Given two positive integer sequences
. . .
Subject to these conditions, maximize
Input Specification
The first line contains an integer
For each test case:
The first line contains three integers
The second line contains
The third line contains
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
Copy
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
Copy
14
12
27
45
62
Comments