fork download
  1. n = int(input())
  2. a = [0] + sorted(list(map(int, input().split())))
  3. q = int(input())
  4. for _ in range(q):
  5. x = int(input())
  6. l = 0; r = n; kq = 0
  7. while l <= r:
  8. m = (l + r) // 2
  9. if x > a[m]:
  10. l = m + 1
  11. kq = m
  12. else: r = m - 1
  13. print(kq)
  14.  
Success #stdin #stdout 0.03s 9620KB
stdin
Standard input is empty
stdout
Standard output is empty