[python] sorted list (or balanced binary tree)
\nfrom sortedcontainers import SortedList\nclass Solution:\n    def closestRoom(self, rooms: List[List[int]], queries: List[List[int]]) -> List[int]:\n        q
```\nfrom sortedcontainers import SortedList\nclass Solution:\n    def closestRoom(self, rooms: List[List[int]], queries: List[List[int]]) -> List[int]:\n        q=sorted([[i,queries[i][0],queries[i][1]] for i in range(len(queries))],key=lambda x:-x[2])\n        r=sorted(rooms,key=lambda x:-x[1])\n        h=SortedList()\n        rr=[-1 for i in q]\n        st=0\n        for i in range(len(q)):\n            while st<len(r) and r[st][1]>=q[i][2]:\n                h.add(r[st][0])\n                st+=1\n            if len(h)==0:continue\n            ii=h.bisect_left(q[i][1])\n            if ii==-1:continue\n            elif ii>=len(h):rr[q[i][0]]=h[len(h)-1]\n            elif ii==0:rr[q[i][0]]=h[ii]\n            else:\n                if abs(h[ii-1]-q[i][1])>abs(h[ii]-q[i][1]):rr[q[i][0]]=h[ii]\n                else:rr[q[i][0]]=h[ii-1]\n        return rr\n```
[]