Company: Zorvyn SDE_4april
Difficulty: medium
Problem Statement You are a consultant who needs to maximize earnings from meetings. You have N potential meetings, each with: Start time S[i] End time E[i] Payment P[i] You can only attend one meeting at a time (meetings cannot overlap). An meeting ending at time t allows starting another meeting at time t (back-to-back is allowed). Find the maximum total payment you can earn. Input Format First line contains a single integer N . Next N lines each contain three integers S , E , P representing a meeting. Output Format Print a single integer - the maximum total payment. Examples Example 1 Input: 4 1 3 50 2 5 60 4 6 70 6 8 80 Output: 200 Explanation: Take meetings [1,3], [4,6], and [6,8]: Meeting [1,3]: payment 50 (ends at 3, next can start at 3 or later) Meeting [4,6]: payment 70 (starts at 4 >= 3, valid) Meeting [6,8]: payment 80 (starts at 6 = end of previous, back-to-back allowed) Total = 50 + 70 + 80 = 200. Other options: [2,5]+[6,8] = 140, [1,3]+[6,8] = 130. Optimal is 200. Exam