Maximum number in array after M operations
Given an array numbered from 1 to N, you need to perform M operations. Each operation is described by 3 values a, b and k. Now, k is added for the range of values starting from index 'a' and ending at index 'b' in the given array. Now, After M operations, you have to calculate the maximum of the values in the array.
Initialize the array to '0' before starting to perform M operations.
Consider the number of elements (N) = 5
Number of operations to perform (M) = 4
When M=1,
a=1, b=2, k=100
When M=2,
a=2, b=5, k=100
When M=3,
a=3, b=4, k=100
Initially the array is 0 0 0 0 0
First operation 100 100 0 0 0
Second operation 100 200 100 100 100
Third operation 100 200 200 200 100
ANS 200