
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Think on DP.
Sort the elements by starting time, then define the dp[i] as the maximum profit taking elements from the suffix starting at i.
Use binarySearch (lower_bound/upper_bound on C++) to get the next index for the DP transition.