CF1152A.Neko Finds Grapes
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
On a random day, Neko found n treasure chests and m keys. The i -th chest has an integer ai written on it and the j -th key has an integer bj on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to open as many treasure chests as possible.
The j -th key can be used to unlock the i -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) . 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.
输入格式
The first line contains integers n and m ( 1≤n,m≤105 ) — the number of chests and the number of keys.
The second line contains n integers a1,a2,…,an ( 1≤ai≤109 ) — the numbers written on the treasure chests.
The third line contains m integers b1,b2,…,bm ( 1≤bi≤109 ) — the numbers written on the keys.
输出格式
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 3 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.