fork download
  1. def wb(t, x):
  2. l = 0
  3. r = len(t) - 1
  4. while l <= r:
  5. m = (l + r) // 2
  6. if t[m] == x:
  7. return m
  8. elif x > t[m]:
  9. l = m + 1
  10. else:
  11. r = m - 1
  12. return -1
  13.  
  14. m = int(input())
  15. k = input().split()
  16. for i in range(m):
  17. k[i] = int(k[i])
  18. m = int(input())
  19. for i in range(m):
  20. hl = int(input())
  21. if wb(k,hl):
  22. print('Yes')
  23. else:print('No')
Success #stdin #stdout 0.03s 9732KB
stdin
7
1 2 6 7 9 9 10
3
4
5
6
stdout
Yes
Yes
Yes