Tap here to switch tabs
Problem
Submissions

Problem: Maximize Meeting Earnings with Idle Gaps

Try to solve the Maximize Meeting Earnings with Idle Gaps problem.

Statement

You are given a 2extD2 ext{D} integer array meetings where meetings[i] = [start_i, end_i, revenue_i] represents a meeting that starts at start_i, ends at end_i, and generates revenue_i in revenue.

You may choose a subset of meetings to attend such that no two chosen meetings overlap. Two meetings do not overlap if the end time of the earlier meeting is less than or equal to the start time of the later meeting.

If you choose a sequence of meetings sorted in chronological order, your total earnings are calculated as the sum of:

  1. The revenue revenue_i of each chosen meeting.

  2. The idle gap duration between each pair of consecutive chosen meetings, defined as the start time of the subsequent meeting minus the end time of the preceding meeting.

Return the maximum total earnings you can achieve.

Constraints:

  • 1≤1 \leq meetings.length ≤105\leq 10^5

  • meetings[i] = [start_i, end_i, revenue_i]

  • 0≤0 \leq start_i << end_i ≤109\leq 10^9

  • 1≤1 \leq revenue_i ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximize Meeting Earnings with Idle Gaps

Try to solve the Maximize Meeting Earnings with Idle Gaps problem.

Statement

You are given a 2extD2 ext{D} integer array meetings where meetings[i] = [start_i, end_i, revenue_i] represents a meeting that starts at start_i, ends at end_i, and generates revenue_i in revenue.

You may choose a subset of meetings to attend such that no two chosen meetings overlap. Two meetings do not overlap if the end time of the earlier meeting is less than or equal to the start time of the later meeting.

If you choose a sequence of meetings sorted in chronological order, your total earnings are calculated as the sum of:

  1. The revenue revenue_i of each chosen meeting.

  2. The idle gap duration between each pair of consecutive chosen meetings, defined as the start time of the subsequent meeting minus the end time of the preceding meeting.

Return the maximum total earnings you can achieve.

Constraints:

  • 1≤1 \leq meetings.length ≤105\leq 10^5

  • meetings[i] = [start_i, end_i, revenue_i]

  • 0≤0 \leq start_i << end_i ≤109\leq 10^9

  • 1≤1 \leq revenue_i ≤109\leq 10^9