boris-vlasenko

767

Oct 27th, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. na = int(input())
  2. a = list(map(int,input().split()))
  3. nb = int(input())
  4. b = list(map(int,input().split()))
  5. a.sort()
  6. b.sort()
  7. i = 1
  8. j = 1
  9. res = 'YES'
  10. if a[0] != b[0]:
  11.     res = 'NO'
  12. else:
  13.     while 1:
  14.         while i < na and a[i] == a[i-1]:
  15.             i += 1
  16.         while j < nb and b[j] == b[j-1]:
  17.             j += 1
  18.         if i < na and j < nb:
  19.             if a[i] != b[j]:
  20.                 res = 'NO'
  21.                 break
  22.             else:
  23.                 i += 1
  24.                 j += 1
  25.         else:
  26.             if i == na and j == nb:
  27.                 break
  28.             else:
  29.                 res = 'NO'
  30.                 break
  31.            
  32.            
  33.        
  34.  
  35.            
  36. print(res)
Advertisement
Add Comment
Please, Sign In to add comment