#abc355b. B - Piano 2

B - Piano 2

Score : 200200 points

问题陈述

给定一个长度为 NN 的序列 A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N) 和一个长度为 MM 的序列 B=(B1,B2,,BM)B=(B_1,B_2,\dots,B_M)。这里,AABB 的所有元素都是两两不同的。确定通过将 AABB 的所有元素按升序排列形成的序列 C=(C1,C2,,CN+M)C=(C_1,C_2,\dots,C_{N+M}) 是否包含两个连续的元素出现在 AA 中。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

You are given a sequence A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N) of length NN and a sequence B=(B1,B2,,BM)B=(B_1,B_2,\dots,B_M) of length MM. Here, all elements of AA and BB are pairwise distinct. Determine whether the sequence C=(C1,C2,,CN+M)C=(C_1,C_2,\dots,C_{N+M}) formed by sorting all elements of AA and BB in ascending order contains two consecutive elements appearing in AA.

Constraints

  • 1N,M1001 \leq N, M \leq 100
  • 1Ai,Bj2001 \leq A_i, B_j \leq 200
  • A1,A2,,AN,B1,B2,,BMA_1, A_2, \dots, A_N, B_1, B_2, \dots, B_M are distinct.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN MM

A1A_1 A2A_2 \dots ANA_N

B1B_1 B2B_2 \dots BMB_M

Output

If CC contains two consecutive elements appearing in AA, print Yes; otherwise, print No.

Sample Input 1

3 2
3 2 5
4 1

Sample Output 1

Yes

C=(1,2,3,4,5)C=(1,2,3,4,5). Since 22 and 33 from AA occur consecutively in CC, print Yes.

Sample Input 2

3 2
3 1 5
4 2

Sample Output 2

No

C=(1,2,3,4,5)C=(1,2,3,4,5). Since no two elements from AA occur consecutively in CC, print No.

Sample Input 3

1 1
1
2

Sample Output 3

No