This is a weighted interval scheduling problem where we maximize total audience instead of count. Sort screenings by end time, then use dynamic programming: for each screening, either skip it or take it plus the best non-overlapping schedule before its start. Precompute the latest non-overlapping screening via binary search to achieve O(n log n) time.
Pro tip: Clarify whether screenings that touch at endpoints (end time equals start time) are considered overlapping; state your assumption and handle it consistently. Also, mention that if all audiences were 1, this reduces to the classic activity selection problem, showing you recognize the generalization.
Confirm input format, whether times are integers or floats, and if back-to-back screenings are allowed. Define the objective: maximize sum of audience sizes of selected non-overlapping screenings.
Sort screenings by end time. For each screening i, use binary search to find p(i), the largest index j < i such that screening j ends before screening i starts (or at the same time if allowed).
Let dp[i] be the max audience using screenings 1..i. Recurrence: dp[i] = max(dp[i-1], audience[i] + dp[p(i)]). Base case dp[0] = 0.
Iterate i from 1 to n to fill dp. Optionally, backtrack to list selected screenings. Return dp[n] as the maximum total audience.
Sorting takes O(n log n), binary search per screening O(log n), DP O(n). Overall O(n log n) time and O(n) space. Mention that a greedy approach fails because audiences are weights.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.