#P3661. [USACO17FEB] Why Did the Cow Cross the Road I S
[USACO17FEB] Why Did the Cow Cross the Road I S
题目背景
征求翻译。如果你能提供翻译(不接受百度翻译等机器翻译)或者题意简述,请直接发讨论,感谢你的贡献。
题目描述
Farmer John's cows are trying to learn to cross the road effectively. Remembering the old "why did the chicken cross the road?" joke, they figure the chickens must be experts on crossing the road, and go off in search of chickens to help them.
农夫约翰的牛们正在尝试去学会高效地穿越马路。熟知经典的笑话“为什么鸡要过马路?”,他们想到鸡一定是过马路的专家,便动身寻找能够帮助它们的鸡。
As it turns out, chickens are very busy creatures and have limited time to help the cows. There are chickens on the farm (), conveniently numbered , and each chicken is only willing to help a cow at precisely time . The cows, never in a hurry, have more flexibility in their schedules. There are cows on the farm (), conveniently numbered , where cow is able to cross the road between time and time . Figuring the "buddy system" is the best way to proceed, each cow would ideally like to find a chicken to help her cross the road; in order for their schedules to be compatible, and must satisfy .
牛们发现,鸡是一种特别繁忙的动物,并且只有一定的时间来帮助它们。农场上共有 只鸡(),十分便利地被编号为, 而且,每只鸡 只有恰好在时间 时才会愿意帮助牛们。而从不慌张的牛们,有更加灵活的时间安排。农场上共有 只牛(),也十分便利地被编号为,牛 在时间 到 之间可以穿过马路。想到“小伙伴系统”是最好的行进方式,每只牛 会理想地愿意找到一只鸡 来帮助她穿过马路;为了是它们的时间表不冲突, 和 必须满足
If each cow can be paired with at most one chicken and each chicken with at most one cow, please help compute the maximum number of cow-chicken pairs that can be constructed.
如果每头奶牛最多只能配一只鸡,而每只鸡最多只配上一头牛,请帮忙计算出可以构造的牛鸡对的最大数量。
输入格式
The first line of input contains and . The next lines contain , and the next lines contain and () for . The 's, 's, and 's are all non-negative integers (not necessarily distinct) of size at most 1,000,000,000
第一行的输入包括 和。下面的 行包括,再接下来的 行包括 和(),。所有 与 都是非负整数(可能相等),并皆小于等于。
输出格式
Please compute the maximum possible number of cow-chicken pairs.
请计算最大的可行牛-鸡配对数。
5 4
7
8
6
2
9
2 5
4 9
0 3
8 13
3
提示
感谢@Darkins 提供翻译