CF1152A.Neko Finds Grapes

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

On a random day, Neko found nn treasure chests and mm keys. The ii-th chest has an integer aia_i written on it and the jj-th key has an integer bjb_j on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to open as many treasure chests as possible.

The jj-th key can be used to unlock the ii-th chest if and only if the sum of the key number and the chest number is an odd number. Formally, ai+bj≡1(mod2)a_i + b_j \equiv 1 \pmod{2}. One key can be used to open at most one chest, and one chest can be opened at most once.

Find the maximum number of chests Neko can open.

在某一天,Neko 发现了 nn 个宝箱和 mm 把钥匙。第 ii 个宝箱上写有一个整数 aia_i,第 jj 把钥匙上写有一个整数 bjb_j。Neko 知道这些宝箱中藏有强大的神秘绿色葡萄,因此他希望尽可能多地打开宝箱。

当且仅当钥匙编号与宝箱编号之和为奇数时,第 jj 把钥匙才能用于打开第 ii 个宝箱。形式化地,即满足 ai+bj≡1(mod2)a_i + b_j \equiv 1 \pmod{2}。每把钥匙最多只能打开一个宝箱,每个宝箱也最多只能被打开一次。

求 Neko 能打开的宝箱数量的最大值。

输入格式

The first line contains integers nn and mm (1≤n,m≤1051 \leq n, m \leq 10^5) — the number of chests and the number of keys.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \leq a_i \leq 10^9) — the numbers written on the treasure chests.

The third line contains mm integers b1,b2,…,bmb_1, b_2, \ldots, b_m (1≤bi≤1091 \leq b_i \leq 10^9) — the numbers written on the keys.

第一行包含两个整数 nn 和 mm(1≤n,m≤1051 \leq n, m \leq 10^5)—— 分别表示宝箱的数量和钥匙的数量。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \leq a_i \leq 10^9)—— 表示写在宝箱上的数字。

第三行包含 mm 个整数 b1,b2,…,bmb_1, b_2, \ldots, b_m(1≤bi≤1091 \leq b_i \leq 10^9)—— 表示写在钥匙上的数字。

输出格式

Print the maximum number of chests you can open.

输出你能打开的宝箱的最大数量。

输入输出样例

  • 输入#1

    5 4
    9 14 6 2 11
    8 4 7 20

    输出#1

    3
  • 输入#2

    5 1
    2 4 6 8 10
    5

    输出#2

    1
  • 输入#3

    1 4
    10
    20 30 40 50

    输出#3

    0

说明/提示

In the first example, one possible way to unlock 33 chests is as follows:

  • Use first key to unlock the fifth chest,
  • Use third key to unlock the second chest,
  • Use fourth key to unlock the first chest.

In the second example, you can use the only key to unlock any single chest (note that one key can't be used twice).

In the third example, no key can unlock the given chest.

在第一个例子中,解锁 33 个宝箱的一种可行方式如下:

  • 使用第一把钥匙解锁第五个宝箱,
  • 使用第三把钥匙解锁第二个宝箱,
  • 使用第四把钥匙解锁第一个宝箱。

在第二个例子中,你可以使用唯一的一把钥匙解锁任意一个宝箱(注意:一把钥匙不能重复使用)。

在第三个例子中,没有任何一把钥匙能够解锁给定的宝箱。

输入解题思路,AI测评打分。不知道怎么写?

首页