406082: GYM102263 D Meeting Bahosain

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

Description

D. Meeting Bahosaintime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Essa wanted to meet the most powerful number theorist of all time: Bahosain, but Bahosain does not waste his precious time, so he gave Essa this puzzle in order to test his abilities.

Given two arrays, the second array only has distinct elements, Essa can do the following as many times as he wants to make all numbers in first array equal.

  1. Choose a number from the first array
  2. Add or subtract from it a number in the second array
  3. Replace the number in the first array with the result
Of course, Essa is unworthy of meeting the almighty Bahosain, and he can't solve this puzzle on his own, so can you help him?Input

The first line containing two space separated integers $$$n,m$$$ ($$$1\le n,k \le 10^6$$$) represent the length of the first and second array.

the second line contains n integers represent the first array ($$$1\le a[i] \le 10^9$$$)

the third line contains m integers represent the second array ($$$1\le b[i] \le 10^9$$$)

Output

Print Yes, if it's possible to make all numbers in first array equal; and No in the opposite case.

ExampleInput
5 2
3 6 7 2 5
2 4
Output
No

Source/Category

加入题单

上一题 下一题 算法标签: