CF297B.Fish Weight
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be w__i, then 0 < _w_1 ≤ _w_2 ≤ ... ≤ w__k holds.
Polar bears Alice and Bob each have caught some fish, and they are guessing who has the larger sum of weight of the fish he/she's caught. Given the type of the fish they've caught, determine whether it is possible that the fish caught by Alice has a strictly larger total weight than Bob's. In other words, does there exist a sequence of weights w__i (not necessary integers), such that the fish caught by Alice has a strictly larger total weight?
已知极地海洋中有 k 种鱼类,编号为 1 到 k。它们按重量的非递减顺序排列,且每种鱼的重量均为正数。设第 i 种鱼的重量为 wi,则满足
0<w1≤w2≤⋯≤wk.
北极熊 Alice 和 Bob 各自捕获了一些鱼,他们正在猜测谁所捕获的鱼的总重量更大。已知他们各自捕获的鱼的种类,判断是否存在一种满足上述约束的重量序列 wi(不一定是整数),使得 Alice 所捕获的鱼的总重量严格大于 Bob 所捕获的鱼的总重量。
输入格式
The first line contains three integers n, m, k (1 ≤ n, m ≤ 105, 1 ≤ k ≤ 109) — the number of fish caught by Alice and Bob respectively, and the number of fish species.
The second line contains n integers each from 1 to k, the list of fish type caught by Alice. The third line contains m integers each from 1 to k, the list of fish type caught by Bob.
Note that one may have caught more than one fish for a same species.
第一行包含三个整数 n、m、k(1≤n,m≤105,1≤k≤109)——分别表示爱丽丝和鲍勃捕获的鱼的数量,以及鱼的种类总数。
第二行包含 n 个整数,每个整数均在 1 到 k 之间,表示爱丽丝捕获的鱼的种类列表。第三行包含 m 个整数,每个整数均在 1 到 k 之间,表示鲍勃捕获的鱼的种类列表。
注意:同一种类的鱼可能被同一人多次捕获。
输出格式
Output "YES" (without quotes) if it is possible, and "NO" (without quotes) otherwise.
如果可能,输出 "YES"(不带引号);否则输出 "NO"(不带引号)。
输入输出样例
输入#1
3 3 3 2 2 2 1 1 3
输出#1
YES
输入#2
4 7 9 5 2 7 3 3 5 2 7 3 8 7
输出#2
NO
说明/提示
In the first sample, if _w_1 = 1, _w_2 = 2, _w_3 = 2.5, then Alice has a total of 2 + 2 + 2 = 6 weight units, while Bob only has 1 + 1 + 2.5 = 4.5.
In the second sample, the fish that Alice caught is a subset of Bob's. Therefore, the total weight of Bob’s fish is always not less than the total weight of Alice’s fish.
在第一个样例中,若 w1=1、w2=2、w3=2.5,则爱丽丝的鱼总重量为 2+2+2=6 个重量单位,而鲍勃的鱼总重量仅为 1+1+2.5=4.5。
在第二个样例中,爱丽丝捕获的鱼是鲍勃所捕鱼的一个子集。因此,鲍勃的鱼总重量始终不小于爱丽丝的鱼总重量。
输入解题思路,AI测评打分。不知道怎么写?