Brute-Force

4.3

3 votes
Medium
Problem

Manmeet always try to solve problems with Brute-Force. But Prince wants to teach him that brute-force don't work always. So, Prince gave him a problem and Manmeet is not able to solve it because he has only Brute-Force solution. Now, Manmeet asked you for help. The problem statement is:

You are given an array of size N initially all elements are 0. You have to perform Q operations on it. In each operation, you will be given L and R denoting range [L,R] in array, and a number K denoting the value to be added in the elements of the range.

Finally you have to output the incremented array elements.

NOTE: Indexing is 0 based in array.

Input Format:

First line contain N and Q denoting number of elements of array and number of operations.

Next Q lines contain L,R and K denoting the range and the value to be added in elements of the range.

Output Format:

Print all the space saperated array elements.

Constraints:

1N,Q5105

0L,R<N

1K100

Time Limit: 0.2
Memory Limit: 256
Source Limit:
Editor Image

?