Most pay from gigs that don't clash
Each gig is a triple [start, end, pay] of integers with start < end and pay > 0. You may take any set of gigs as long as no two of them overlap in time; a gig that starts exactly when another ends does not clash with it. Return the largest total pay you can earn.
The list is not sorted and may be empty (then the answer is 0). It can be long: trying every subset, or comparing every pair of gigs, is too slow. Aim for O(n log n).
Besides the tests, one large input (4,500 gigs) with a ~200 ms limit (scaled to your device's speed): brute force won't pass.
Examples
max_pay([[1,3,50],[2,4,10],[3,5,40],[3,6,70]])→120max_pay([[1,2,5],[1,10,100],[2,3,5],[3,4,5]])→100max_pay([[1,2,5],[2,3,5],[3,4,5]])→15