439. Range Updates With a Difference Array
MediumPrefix Sum
Start with n zeros. Each update adds v to positions l..r (1-based, inclusive). Print the final array.
Input format
Line 1: n q Next q lines: l r v
Output format
The final array.
Example 1
Input
5 3 1 2 10 2 3 20 2 5 25
Output
10 55 45 25 25
Example 2
Input
3 1 1 3 -1
Output
-1 -1 -1
Constraints
1 ≤ n, q ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…