Range Additions
View as PDF
Submit solution
Points:
100
Time limit:
1.0s
PyPy 3
2.0s
Python 3
2.0s
Memory limit:
977M
Problem type
You are given an array of integers.
Then queries follow. Each query contains three integers
and means to add
to
every element from
to
, inclusive.
After processing all queries, print the final array.
Input
The first line contains two integers and
, the length of the array and the number of
queries.
The second line contains integers:
.
Each of the next lines contains three integers
, meaning add
to every element
.
Output
Print space-separated integers: the final contents of the array after all
queries are
applied.
Constraints
Example 1
Input
5 3
1 2 3 4 5
1 3 2
2 5 -1
4 4 7
Output
3 3 4 10 4
Explanation
After the three updates, the array becomes .
Example 2
Input
6 4
0 0 0 0 0 0
1 6 5
2 4 -3
3 3 10
6 6 -2
Output
5 2 12 2 5 3
Example 3
Input
4 0
8 -3 14 1
Output
8 -3 14 1
Comments