Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- na = int(input())
- a = list(map(int,input().split()))
- nb = int(input())
- b = list(map(int,input().split()))
- a.sort()
- b.sort()
- i = 1
- j = 1
- res = 'YES'
- if a[0] != b[0]:
- res = 'NO'
- else:
- while 1:
- while i < na and a[i] == a[i-1]:
- i += 1
- while j < nb and b[j] == b[j-1]:
- j += 1
- if i < na and j < nb:
- if a[i] != b[j]:
- res = 'NO'
- break
- else:
- i += 1
- j += 1
- else:
- if i == na and j == nb:
- break
- else:
- res = 'NO'
- break
- print(res)
Advertisement
Add Comment
Please, Sign In to add comment