Maximum Number of Events That Can Be Attended II
You are given an array of events where events[i] = [startDayi, endDayi, valuei]. The i^th event starts at startDayi and ends at endDayi, and if you attend this event, you will receive a value of valuei. You are also given an integer k, which represents the maximum number of events you can attend.
You can only attend one event at a time. If you choose to attend an event, you must attend the entire event. Note that the end day is inclusive: that is, you cannot attend two events where one of them starts and the other ends on the same day.
Return the maximum sum of values that you can receive by attending events.
Example 1
Input
events = [[1,2,4],[3,4,3],[2,3,1]], k = 2Output
7Choose events 0 and 1 for a total value of 4 + 3 = 7.
Example 2
Input
events = [[1,2,4],[3,4,3],[2,3,10]], k = 2Output
10Choose event 2 for a total value of 10; you cannot attend any other event because they overlap, and you do not have to attend k events.
Constraints
- 1 <= k <= events.length
- 1 <= k * events.length <= 10^6
- 1 <= startDayi <= endDayi <= 10^9
- 1 <= valuei <= 10^6