Given an array of n
elements. Initially all of them are zero. We need to process three type of queries:
- assign value
v
to all elements on the segment froml
tor
, - add
v
to all elements on the segment froml
tor
, - find the sum on the segment from
l
tor
.
We can solve this problem by doing some simple loops. But the problem is there are as much as 100000 queries of these three types. So, this method will take much time. That's why I tried using segment tree and lazy propagation to solve this problem, but couldn't solve it. How to solve this problem?
This problem is from here.