Custom Sort Greedily
\nfrom functools import cmp_to_key\n\nclass Solution:\n    def minimumEffort(self, tasks: List[List[int]]) -> int:\n        def cmp(a, b):\n            if max(a
```\nfrom functools import cmp_to_key\n\nclass Solution:\n    def minimumEffort(self, tasks: List[List[int]]) -> int:\n        def cmp(a, b):\n            if max(a[1], a[0] + max(b[0], b[1])) > max(b[1], b[0] + max(a[0], a[1])):\n                return 1\n            return -1\n        tasks.sort(key = cmp_to_key(cmp))\n        res = 0\n        used = 0\n        for i in range(len(tasks)):\n            res = max(res, used + tasks[i][1])\n            used += tasks[i][0]\n        return res\n```
['Python']