Simple Solution
Code

# Code
```cpp []
class Solution {
public:
    long long maximumCoins(vector<vector<int>>& coins, long long k) {
        // Sort coins intervals by their start time
        sort(coins.begin(), coins.end());
        queue<vector<long long>> q; // Store intervals: [start, end, coins]
        long long sum = 0;         // Current sum of coins in the sliding window
        long long ans = 0;         // Maximum coins collected
        int n = coins.size();

        for (int i = 0; i < n; i++) {
            int start = coins[i][0], end = coins[i][1];
            long long value = coins[i][2];

            // Remove intervals from the queue that are no longer valid
            while (!q.empty() && q.front()[1] + k - 1 < start) {
                sum -= (q.front()[1] - q.front()[0] + 1) * q.front()[2];
                q.pop();
            }

            // Adjust the front interval if it overlaps too much with the current interval
            while (!q.empty() && end - k + 1 > q.front()[0]) {
                long long lastVal = q.front()[0] + k - 1;
                ans = max(ans, sum + max(0LL, lastVal - start + 1) * value);

                int minVal = end - k + 1;
                if (minVal <= q.front()[1]) {
                    sum -= (minVal - q.front()[0]) * q.front()[2];
                    q.front()[0] = minVal;
                } else {
                    sum -= (q.front()[1] - q.front()[0] + 1) * q.front()[2];
                    q.pop();
                }
            }

            // Add the current interval to the queue
            int count = end - start + 1;
            if (count <= k) {
                sum += count * value;
                q.push({start, end, value});
            } else {
                sum += k * value;
                q.push({end - k + 1, end, value});
            }

            // Update the maximum coins collected
            ans = max(ans, sum);
        }

        return ans;
    }
};

```
['C++']