A12491 | Neko Finds Grapes
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
On a random day, Neko found $n$ treasure chests and $m$ keys. The $i$ -th chest has an integer $a_i$ written on it and the $j$ -th key has an integer $b_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 $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, $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.
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, $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.
输入格式
The first line contains integers $n$ and $m$ ( $1 \leq n, m \leq 10^5$ ) — the number of chests and the number of keys.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \leq a_i \leq 10^9$ ) — the numbers written on the treasure chests.
The third line contains $m$ integers $b_1, b_2, \ldots, b_m$ ( $1 \leq b_i \leq 10^9$ ) — the numbers written on the keys.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \leq a_i \leq 10^9$ ) — the numbers written on the treasure chests.
The third line contains $m$ integers $b_1, b_2, \ldots, b_m$ ( $1 \leq b_i \leq 10^9$ ) — 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.
- 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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted