You are given a 0-indexed array of size n, initially filled with zeros. You have to perform m operations on this array.
Each operation is defined by a triplet (a, b, k), which instructs you to add the value k to every element of the array from index a to index b, inclusive.
After performing all m operations, your task is to find and return the maximum value in the final array.
Input Format:
The first line of input contains two space-separated integers, n and m.
The next m lines each contain three space-separated integers, a, b, and k.
Output Format:
Print a single integer representing the maximum value in the array after all operations are complete.
Note:
A naive solution of actually performing the additions for each query would be O(m * n), which is too slow for the given constraints.