from math import infn, x, y = map(int, input().split())t = lambda u : int(u)events = [list(map(t, input().split())) for _ in range(n)]v = list(map(t, input().split()))w = list(map(t, input().split()))v.sort()w.sort()for e in events:e.extend([-inf, inf])#Nearest V for each event starting:events.sort(key = lambda x : x[0]) #sort by startvi, i = 0, 0pvi = -infwhile vi < x and i < n:if v[vi] <= events[i][0]:events[i][2] = v[vi]pvi = v[vi]vi += 1else:events[i][2] = pvii += 1#Nearest W for each event ending:events.sort(key = lambda x : x[1]) #sort by end

Read more…