# Maximum Meeting Earnings Including Idle Gaps
You are given `meetings`, where each row is `[start, end, revenue]`.
Select a nonempty subset of meetings that do not overlap. Meetings occupy half-open intervals `[start, end)`, so a meeting ending exactly when another starts is compatible with it.
Earn each selected meeting's revenue. Also earn one unit per unit of idle time between consecutive selected meetings in chronological order. For such a pair, the idle bonus is the later start time minus the earlier end time.
No idle bonus is earned before the first selected meeting or after the last. A schedule containing just one meeting earns only its stated revenue.
Return the maximum total earnings.
### Function
`long long maxEarnings(vector<vector<int>>& meetings)`
### Example 1
**Input:** `meetings = [[0, 1, 2], [1, 10, 1], [10, 11, 2]]`
**Output:** `13`
**Explanation:** Select the first and last meetings. Their revenues total `4`, and the idle interval from time `1` to time `10` contributes `9`, giving `13`. Selecting all three meetings would earn only `5`, because it removes that idle interval.
### Example 2
**Input:** `meetings = [[2, 4, 5], [4, 7, 6], [3, 8, 10]]`
**Output:** `11`
**Explanation:** The first two meetings touch at time `4` without overlapping. Together they earn `5 + 6 = 11`, with a zero-length idle gap. The third meeting overlaps both and earns only `10` if selected alone. No bonus is added before time `2` or after time `7`.
### Constraints
- `1 <= meetings.length <= 100000`
- Each row contains exactly `[start, end, revenue]`.
- `0 <= start < end <= 1000000000`
- `1 <= revenue <= 1000000000`
### Clarifications
- Meetings may be supplied in any order.
- Idle gaps are measured only between adjacent selected meetings, not between every pair.
- All selected meetings must be nonoverlapping, and at least one must be selected.
- A positive-revenue meeting may be worth skipping because it would replace an otherwise profitable idle gap.
### What a Strong Answer Covers
- Combining meeting revenue with the correct gaps between chosen neighbors.
- Respecting half-open endpoint compatibility and the nonempty-schedule requirement.
- Handling large timestamps and total earnings without adding idle time outside the selected schedule.
Overview: Maximize earnings from a nonempty set of nonoverlapping half-open meetings, including idle-time bonuses only between consecutive selected meetings.
You are given meetings, where each row is [start, end, revenue].
Select a nonempty subset of meetings that do not overlap. Meetings occupy half-open intervals [start, end), so a meeting ending exactly when another starts is compatible with it.
Earn each selected meeting's revenue. Also earn one unit per unit of idle time between consecutive selected meetings in chronological order. For such a pair, the idle bonus is the later start time minus the earlier end time.
No idle bonus is earned before the first selected meeting or after the last. A schedule containing just one meeting earns only its stated revenue.
Return the maximum total earnings.
Function
long long maxEarnings(vector<vector<int>>& meetings)
Explanation: Select the first and last meetings. Their revenues total 4, and the idle interval from time 1 to time 10 contributes 9, giving 13. Selecting all three meetings would earn only 5, because it removes that idle interval.
Explanation: The first two meetings touch at time 4 without overlapping. Together they earn 5 + 6 = 11, with a zero-length idle gap. The third meeting overlaps both and earns only 10 if selected alone. No bonus is added before time 2 or after time 7.
Constraints
1 <= meetings.length <= 100000
Each row contains exactly
[start, end, revenue]
.
0 <= start < end <= 1000000000
1 <= revenue <= 1000000000
Clarifications
Meetings may be supplied in any order.
Idle gaps are measured only between adjacent selected meetings, not between every pair.
All selected meetings must be nonoverlapping, and at least one must be selected.
A positive-revenue meeting may be worth skipping because it would replace an otherwise profitable idle gap.
What a Strong Answer Covers Guidance
Combining meeting revenue with the correct gaps between chosen neighbors.
Respecting half-open endpoint compatibility and the nonempty-schedule requirement.
Handling large timestamps and total earnings without adding idle time outside the selected schedule.