cswork / OA打开练习工作台

MicrosoftOA #2

Smallest Missing Positive after Merging A and B

估计中等可在线判题

考点(AI 标注)哈希计数

At each position choose either A[i] or B[i] to form C, so that the smallest missing positive integer of C is as small as possible. This site judges by "minimize the missing value"; the original site described it as a number that cannot appear in any C, which contradicts its examples.

输入格式

The first line contains N (1..100000), the second line contains A, and the third line contains B, each with N integers in 1..100000.

输出格式

Output a single integer, the answer.

样例 1

输入:

4
1 2 4 3
1 3 2 3

输出:

2

样例 2

输入:

5
3 2 1 6 5
4 2 1 3 3

输出:

3

样例 3

输入:

2
1 2
1 2

输出:

3

样例说明

Example 1: 1 and 3 are forced to appear by fixed positions, while 2 can be avoided; the answer is 2.

Example 2: 1 and 2 are forced to appear, and 3 can be avoided at every position; the answer is 3.

Example 3: the two positions can only pick 1 and 2, so the smallest missing number is 3.