[Python3] binary search
\n\nclass Solution:\n    def maxTwoEvents(self, events: List[List[int]]) -> int:\n        time = []\n        vals = []\n        ans = prefix = 0\n        for st
\n```\nclass Solution:\n    def maxTwoEvents(self, events: List[List[int]]) -> int:\n        time = []\n        vals = []\n        ans = prefix = 0\n        for st, et, val in sorted(events, key=lambda x: x[1]): \n            prefix = max(prefix, val)\n            k = bisect_left(time, st)-1\n            if k >= 0: val += vals[k]\n            ans = max(ans, val)\n            time.append(et)\n            vals.append(prefix)\n        return ans \n```\n\n```\nclass Solution:\n    def maxTwoEvents(self, events: List[List[int]]) -> int:\n        ans = most = 0 \n        pq = []\n        for st, et, val in sorted(events): \n            heappush(pq, (et, val))\n            while pq and pq[0][0] < st: \n                _, vv = heappop(pq)\n                most = max(most, vv)\n            ans = max(ans, most + val)\n        return ans \n```
['Python3']