QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 70

#13376. Zrinka

Statistics

给定两个长度分别为 $n$ 和 $m$ 的数组,它们仅由 $0$ 和 $1$ 组成。

你的任务是将每个 $0$ 替换为一个正偶数,将每个 $1$ 替换为一个正奇数。替换后,两个数组都必须是递增的,且每个正整数最多只能使用一次。

为了增加难度,要求你使得所使用的最大数字尽可能小。

给定两个数组,输出需要使用的最小可能的最大数字。

输入格式

第一个数组长度为 $n$ ($0 \le n \le 5000$),第二个数组长度为 $m$ ($1 \le m \le 5000$)。 第一行包含 $n+1$ 个整数,第一个整数为 $n$,其余整数描述第一个数组。 第二行包含 $m+1$ 个整数,第一个整数为 $m$,其余整数描述第二个数组。

输出格式

第一行且仅包含一个正整数,即上述问题的答案。

子任务

子任务 分值 数据范围
1 15 $n = 0$
2 20 第一个数组仅由 $0$ 组成
3 15 $n, m \le 500$
4 20 无附加限制

样例

输入格式 1

0
4 1 0 1 1

输出格式 1

5

输入格式 2

4 0 1 0 1
4 1 0 0 1

输出格式 2

9

说明

其中一种可能的解为 $(2, 3, 4, 5)$ 和 $(1, 6, 8, 9)$。

输入格式 3

5 0 1 0 0 1
4 0 0 0 1

输出格式 3

13

说明

其中一种可能的解为 $(2, 3, 6, 8, 9)$ 和 $(4, 10, 12, 13)$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.