Sorting + greedy + binary search
Code


# Code
```python3 []
class Solution:
    def maximumCoins(self, coins: List[List[int]], k: int) -> int:
        coins.sort()
        starts = [a for a,b,c in coins]
        ends = [b for a,b,c in coins]
        vals = [c for a,b,c in coins]
        pres = [0]
        for a,b,c in coins:
            pres.append(c*(b-a+1)+pres[-1])
        res = 0
        N = len(coins)
        for i,s in enumerate(starts):
            curr = 0
            j = bisect.bisect_right(ends,s+k-1)
            curr += pres[j]-pres[i]
            if j<N and starts[j]<=s+k:
                curr += (s+k-starts[j])*vals[j]
            res = max(curr,res)
        for j,e in enumerate(ends):
            curr = 0
            i = bisect.bisect_left(starts,e-k+1)
            curr += pres[j+1]-pres[i]
            if i>0 and ends[i-1]>=e-k:
                curr += (ends[i-1]-e+k)*vals[i-1]
            res = max(curr,res)
        return res
        
```
['Binary Search', 'Greedy', 'Sorting', 'Python3']