Comments

Glad to know :D

Solved it using the link. here's the AC code : http://ideone.com/kTHEpl Sorry I made a mistake. You can either Here's how I did it : http://ideone.com/nBUWgZ The only change in my code is that in my lazy update I'm updating the lazyval as the sum of subtree i.e : lazy[L] += ( lazy[stIndex]/(p.S — p.F + 1) )*(mid — p.F + 1); and icrementing the tree value by the lazy node i.e. tree[i] += lazy[i];

That is true , I made a mistake.Sorry. I solved it again with the link given above

lazy update is wrong. it should be like this : lazy[L(p)] += value*(mid — left_index + 1); because the update query contains the whole range update not just a single value