102411: [AtCoder]ABC241 B - Pasta

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

Description

Score : $200$ points

Problem Statement

There is pasta consisting of $N$ noodles at Takahashi's home. The length of the $i$-th noodle is $A_i$.
Takahashi has a meal plan for the next $M$ days. On the $i$-th day, he is going to choose a pasta noodle of length exactly $B_i$ and eat it. If no such noodle is available on any day, his plan fails. Additionally, he cannot eat the same noodle on multiple days.

Can Takahashi accomplish his meal plan?

Constraints

  • $1 \leq M \leq N \leq 1000$
  • $1 \leq A_i \leq 10^9$
  • $1 \leq B_i \leq 10^9$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $M$
$A_1$ $A_2$ $\ldots$ $A_N$
$B_1$ $B_2$ $\ldots$ $B_M$

Output

If Takahashi can accomplish his meal plan, print Yes; otherwise, print No.


Sample Input 1

3 2
1 1 3
3 1

Sample Output 1

Yes

He can eat the $3$-rd noodle on the $1$-st day and the $1$-st noodle on the $2$-nd day, so his meal plan is feasible.


Sample Input 2

1 1
1000000000
1

Sample Output 2

No

A noodle of length exactly $1$ is needed.


Sample Input 3

5 2
1 2 3 4 5
5 5

Sample Output 3

No

Since there are only $1$ noodle of length $5$, he cannot have a meal on the $2$-nd day.

Input

题意翻译

小A有$N$个数字,第 $i$ 个数字是 $A_i$。 他制定了今后 $M$ 天的计划,第 $i$ 天他想要的数字是$B_i$。每天他想选 $1$ 个这样的数。如果从第 $1$ 天到 $M$ 天之间有任何 $1$ 天没有那样的数字,计划就会失败。另外,一个数字只能选一次。 判断小A是否可以完成他的计划。

Output

得分:200分

问题描述

高桥家有N根意大利面。第i根意大利面的长度是A_i。
高桥有一个未来M天的饮食计划。在第i天,他要选择一根长度为B_i的意大利面吃掉。如果某一天找不到符合条件的面条,他的计划就会失败。此外,他不能在不同的日子吃同一根面条。

高桥能完成他的饮食计划吗?

约束

  • 1≤M≤N≤1000
  • 1≤A_i≤10^9
  • 1≤B_i≤10^9
  • 输入中的所有值都是整数。

输入

输入以标准输入的以下格式给出:

$N$ $M$
$A_1$ $A_2$ $\ldots$ $A_N$
$B_1$ $B_2$ $\ldots$ $B_M$

输出

如果高桥能完成他的饮食计划,打印Yes;否则,打印No


样例输入1

3 2
1 1 3
3 1

样例输出1

Yes

他可以在第一天吃第3根面条,在第二天吃第1根面条,所以他的饮食计划是可行的。


样例输入2

1 1
1000000000
1

样例输出2

No

需要一根长度正好为1的面条。


样例输入3

5 2
1 2 3 4 5
5 5

样例输出3

No

因为只有1根长度为5的面条,所以他在第二天无法吃餐。

加入题单

算法标签: