🎁 Exclusive Offer! Join our
Telegram Channel
to get **special discounts** and updates! 🚀
Question 82 - 100% Working Solution | Buy Now
Description
7 Live
There are N trolleys used to transport products and each trolley is given a unique ID from 0 to N-1. A trolley operates for a certain time period and is able to carry products. For each trolley, the automated system stores three parameters i.e., the start and end time of operation (both inclusive) and units of products carried. A trolley can be operated within a specified period. No two trolleys can be operated during the same period, but if a trolley's operating period ends at point T, then another trolley can be immediately started at T. The system must store the maximum number of products transported.
Write an algorithm to find the maximum number of products transported.
Input
The first line of the input consists of two space-separated integers - trolleyList_row and trolleyList_col, representing the number of trolleys (N) and the number of parameters associated with each trolley (trolleyList_col(M) is always equal to three).
The next N lines consist of M space-separated integers representing the starting of the period, ending of the period and, the number of products carried by the trolley, respectively.
Output
Print an integer representing the maximum number of products transported.
Constraints
0 ≤ trolleyList_row ≤ 10^4
0 ≤ starting of the period, ending of the period ≤ 1000
0 < number of products carried by the trolley ≤ 104
trolleyList_col = 3
Example
Input:
4 3
0 2 4
0 4 9
2 4 6
5 10 20
Output:
30