simple sorted list
\nfrom sortedcontainers import SortedList\nclass Solution:\n    def closestRoom(self, rooms: List[List[int]], queries: List[List[int]]) -> List[int]:\n        s
```\nfrom sortedcontainers import SortedList\nclass Solution:\n    def closestRoom(self, rooms: List[List[int]], queries: List[List[int]]) -> List[int]:\n        self.q_map = {}\n        self.n = len(queries)\n        self.big = 10**8+7\n        i = self.n-1\n        while len(queries) > 0:\n            pref, size = queries.pop()\n            self.q_map.setdefault(size, [])\n            self.q_map[size].append((i, pref))\n            i -= 1\n        self.qs = list(self.q_map)\n        self.qs.sort()\n        #print(self.q_map)\n        #print(self.qs)\n        \n        self.my_rm = []\n        while len(rooms) > 0:\n            rid, s = rooms.pop()\n            self.my_rm.append((s, rid))\n        self.my_rm.sort()\n        #print(self.my_rm)\n        \n        self.rst = [-1 for i in range(self.n)]\n        self.bigger = SortedList()\n        while len(self.qs) > 0:\n            s = self.qs.pop()\n            while len(self.my_rm) > 0 and self.my_rm[-1][0] >= s:\n                _, rid = self.my_rm.pop()\n                self.bigger.add(rid)\n            if len(self.bigger) == 0:\n                print(\'wahaha\')\n                continue\n            for i, pref in self.q_map[s]:\n                loc = self.bigger.bisect_left(pref)\n                dist = self.big\n                p = -1\n                if loc > 0 and abs(pref - self.bigger[loc-1]) < dist:\n                    dist = abs(pref - self.bigger[loc-1])\n                    assert dist >= 0\n                    p = self.bigger[loc-1]\n                if loc < len(self.bigger) and self.bigger[loc] - pref < dist:\n                    dist = self.bigger[loc] - pref\n                    assert dist >= 0\n                    p = self.bigger[loc]\n                self.rst[i] = p\n        return self.rst\n```
[]