A promotional campaign will add a fixed bonus to sales across various date ranges, and Shuvo needs the final adjusted sales figures after all these range-wide bonuses are applied. Start with an array of N zeros. Process Q update operations, each adding value V to every element in range [L,R] (1-indexed, inclusive). After all updates, print the final array. Use the difference-array technique so each update is O(1), not O(N).
Input
Line1: N Q. Next Q lines: L R V.
Output
The final array, N space-separated integers.
Constraints
1 ≤ N,Q ≤ 10^5, |V| ≤ 10^4
Sample Input
5 2 1 3 2 2 5 3
Sample Output
2 5 5 3 3
main.c
Loading editor…
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.