#C5682. Array Manipulation: Maximum Value after Operations

    ID: 49358 Type: Default 1000ms 256MiB

Array Manipulation: Maximum Value after Operations

Array Manipulation: Maximum Value after Operations

You are given an array of n elements, all initially set to zero. You are also given a list of operations. Each operation is represented by three integers a, b, k and involves adding the value k to each array element with index in the range [a, b] (both inclusive). Your task is to determine the maximum value in the array after all operations have been applied.

The operation can be mathematically described as follows:

For each operation, for all indices \( i \) such that \( a \le i \le b \), update
\( A[i] = A[i] + k \).

Finally, output the value \( \max_{1 \le i \le n} A[i] \).

inputFormat

The first line of the input contains two space-separated integers n and m, where n is the size of the array and m is the number of operations.

Each of the next m lines contains three space-separated integers a, b, and k representing an operation. It is guaranteed that 1 ≤ a ≤ b ≤ n.

outputFormat

Output a single integer, which is the maximum value in the array after all operations are applied.

## sample
5 3
1 2 100
2 5 100
3 4 100
200