Advertisement
Bad_Programist

Untitled

Jan 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. Num1 = int(input())
  2. Color1 = list(map(int, input().split()))
  3. Num2 = int(input())
  4. Color2 = list(map(int, input().split()))
  5. i = 0
  6. j = 0
  7. res = 'NO'
  8. while i < Num1 and j < Num2:
  9.     if abs(Color1[i] - Color2[j]) == 1:
  10.         res = 'YES'
  11.         break
  12.     if Color1[i] < Color2[j]:
  13.         i += 1
  14.     else:
  15.         j += 1
  16. print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement