Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@codeantik | 448 |

@SherlockHolmes3 | 447 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

Complete Leaderboard |

Given an array of size **N** with all initial values as 0, write a program to perform following **M** range increment operations as shown below:** **

```
increment(a, b, k) : Increment values from 'a'
to 'b' by 'k'.
After M operations, calculate the maximum value
in the array.
```

**Input:**

First line of input contains a single integer T which denotes the number of test cases. T test cases follows. First line of each test case contains two space separated integers N and M. Next M lines of each test case contains three space separated integers a , b and k.

**Output:**

For each test case print the maximum element in the array after M increment operations.

**Constraints:**

1<=T<=100

1<=N<=10^{5}

1<=M<=1000

0<= a,b <= N-1

**Example:
Input:**

2

5 3

0 1 100

1 4 100

2 3 100

4 3

1 2 603

0 0 286

3 3 882

200

882

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Max value after m range operation

...