#P9173. [COCI 2022/2023 #4] Zrinka
[COCI 2022/2023 #4] Zrinka
Problem Description
You are given two arrays of length and , and they consist only of and .
Your task is to replace each with an even number, and each with an odd number.
After the replacement, both arrays should be non-decreasing, all elements should be greater than , and you may use each positive integer at most once. The largest number used should be as small as possible.
Input Format
The first line contains integers. The first one is , and the others describe the first array.
The second line contains integers. The first one is , and the others describe the second array.
Output Format
Output one positive integer on one line, which is the largest number.
0
4 1 0 1 1
5
4 0 1 0 1
4 1 0 0 1
9
5 0 1 0 0 1
4 0 0 0 1
13
Hint
Explanation for Sample :
One feasible solution is: .
Explanation for Sample :
One feasible solution is: .
Explanation for Sample :
One feasible solution is: .
| Subtask ID | Additional Constraints | Score |
|---|---|---|
| Sample only | ||
| The first array contains only | ||
| No additional constraints |
Translated by ChatGPT 5