#P13994. 【MX-X19-T3】「LAOI-14」Another Round
【MX-X19-T3】「LAOI-14」Another Round
Description
Given a positive integer and two integer sequences and of length , where is guaranteed to be non-negative, but may be negative.
Define the notation to represent the set .
For each , you need to select a subset of with size . Under this constraint, find the maximum value of
$$\Bigl( \max_{i \in S} a_i \Bigr) - \Bigl( \operatorname*{mex}_{i \in S} b_i \Bigr).$$Note: denotes the minimum non-negative integer that does not appear in .
Input Format
The input contains multiple test cases.
The first line contains an integer , indicating the number of test cases. For each test case:
- The first line contains a positive integer .
- The second line contains integers .
- The third line contains non-negative integers .
Output Format
For each test case, output lines. The -th line should contain one integer, which is the answer when .
1
3
1 2 3
0 0 1
3
1
1
4
4
9 1 2 0
9 3 7 8
5
4 8 8 9 4
4 9 0 7 8
6
3 9 4 6 2 5
6 4 6 5 8 2
5
5 2 2 4 4
0 1 4 2 1
9
9
9
9
9
9
9
9
8
9
9
9
9
9
9
4
4
4
4
2
2
6
0 0 0 0 0 0
6 5 2 7 1 6
6
6 5 0 7 9 2
0 0 0 0 0 0
0
0
0
0
0
0
8
8
8
8
8
8
Hint
【Sample Explanation #1】
When , let , then the answer is .
When , let , then the answer is .
When , let , then the answer is .
【Data Range】
This problem uses bundled testing.
| Subtask ID | Special Properties | Score | |
|---|---|---|---|
| C | |||
| AC | |||
| BC | |||
| C | |||
| None |
- Special Property A: .
- Special Property B: .
- Special Property C: .
For all test cases, , , .
Translated by DeepSeek V3.1
京公网安备 11011102002149号