题目描述
Problem Description
You are given two arrays of lengths $n$ and $m$, consisting only of $0$s and $1$s.
Your task is to replace each $0$ with an even number and each $1$ with an odd number.
After replacement, both arrays should be monotonically increasing with all elements greater than $0$, and you can use each positive integer at most once, with the maximum number used being as small as possible.
Input Format
The first line consists of $n+1$ integers, the first being $n(n\leq 5000)$, followed by the description of the first array.
The second line consists of $m+1$ integers, the first being $m(m\leq 5000)$, followed by the description of the second array.
Output Format
A single positive integer, which is the maximum number used.
Sample Input and Output
Sample Input #1
0
4 1 0 1 1
Sample Output #1
5
Sample Input #2
4 0 1 0 1
4 1 0 0 1
Sample Output #2
9
Sample Input #3
5 0 1 0 0 1
4 0 0 0 1
Sample Output #3
13
Notes
Sample $1$ Explanation:
A possible solution: $(\varnothing),(1,2,3,5)$
Sample $2$ Explanation:
A possible solution: $(2,3,4,5),(1,6,8,9)$
Sample $3$ Explanation:
A possible solution: $(2, 3, 6, 8, 9),(4,10,12,13)$
| Subtask Number | Additional Constraints | Score |
|---|---|---|
| $0$ | Sample | $0$ |
| $1$ | $n=0$ | $15$ |
| $2$ | First array only includes $0$ | $20$ |
| $3$ | $n,m\leq 500$ | $20$ |
| $4$ | No additional constraints | $7$ |
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分