loj#P3158. 「NOI2019」序列
「NOI2019」序列
Description
You are given two sequences and of length , and the element of them are indexed from to . You need to choose numbers in each sequence, and ensure that at least positions are chosen in both sequences. Your task is to maximize the sum of the numbers.
Formally speaking, you need to assign sequences and of length such that
- $\left\lvert\{c_1, c_2, \cdots, c_K\} \cap \{d_1, d_2, \cdots, d_K\}\right\rvert \geq L$
Your goal is to maximize
Input
The first line contains a single integer — the number of test cases.
Each test case contains lines.
The first line contains integers .
The second line contains integers .
The third line contains integers .
Output
For each test case, print a single integer — the maximal sum.
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
14
12
27
45
62
Limits And Hints
For all of the tests, , , , .
For partial scores, you can look up at the origin statement (NOI/2019/Day1.pdf
).