Stacked Range Additions
Starting from an all-zero array of length N, apply M updates 'add V to every element in [L, R]'. Print the final array.
Input: the first line has N and M; each of the next M lines has L R V.
Output: the final N values.
Constraints:
- 1 ≤ N, M ≤ 105
- |V| ≤ 100
Sample Tests
Input 1
5 2 1 3 2 2 5 1
Output 1
2 3 3 1 1
Input 2
1 1 1 1 -5
Output 2
-5
Discussion (opens after you solve — no spoilers before)
No comments yet.