Advertisement
skate1512

CSES - Concert Tickets 2

Oct 23rd, 2020
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. from sys import stdin, stdout
  2. from bisect import bisect_left
  3. n, m = map(int, stdin.readline().split())
  4. h = list(map(int, stdin.readline().split()))
  5. h.sort()
  6. t = list(map(int, stdin.readline().split()))
  7. p = []
  8. for i in t:
  9.     v = bisect_left(h, i + 1)
  10.     if v <= 0:
  11.         p.append("-1")
  12.     else:
  13.         r = h.pop(v - 1)
  14.         p.append(str(r))
  15. stdout.write("\n".join(p))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement