302531: CF489B. BerSU Ball

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

BerSU Ball

题意翻译

有n个男孩和m个女孩(1≤n,m≤100),我们知道他们每个人的技能值(男孩为a[i],女孩为b[i],每个技能值都≤100)。 当且仅当第A个男孩和第B个女孩的技能值相差不超过1时,他们将成为一对舞伴。 给定n、m和他们各自的技能值,输出他们能组成的舞伴最大对数(格式见样例)。

题目描述

The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! $ n $ boys and $ m $ girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves. We know that several boy&girl pairs are going to be invited to the ball. However, the partners' dancing skill in each pair must differ by at most one. For each boy, we know his dancing skills. Similarly, for each girl we know her dancing skills. Write a code that can determine the largest possible number of pairs that can be formed from $ n $ boys and $ m $ girls.

输入输出格式

输入格式


The Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! $ n $ boys and $ m $ girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves. We know that several boy&girl pairs are going to be invited to the ball. However, the partners' dancing skill in each pair must differ by at most one. For each boy, we know his dancing skills. Similarly, for each girl we know her dancing skills. Write a code that can determine the largest possible number of pairs that can be formed from $ n $ boys and $ m $ girls.

输出格式


Print a single number — the required maximum possible number of pairs.

输入输出样例

输入样例 #1

4
1 4 6 2
5
5 1 5 7 9

输出样例 #1

3

输入样例 #2

4
1 2 3 4
4
10 11 12 13

输出样例 #2

0

输入样例 #3

5
1 1 1 1 1
3
1 2 3

输出样例 #3

2

Input

题意翻译

有n个男孩和m个女孩(1≤n,m≤100),我们知道他们每个人的技能值(男孩为a[i],女孩为b[i],每个技能值都≤100)。 当且仅当第A个男孩和第B个女孩的技能值相差不超过1时,他们将成为一对舞伴。 给定n、m和他们各自的技能值,输出他们能组成的舞伴最大对数(格式见样例)。

加入题单

上一题 下一题 算法标签: