can you help ,i am unable to think an approach.
Array queries I
Here is the approach of the problem:
We can initially compute f(i,k) for all 1<=i<=N. We can build a sum segment tree initially. Now whenever an update comes, we know that each element is added to some f(i,k) for i in a range. So we can lazily update at all the positions, i(it will be a range or two ranges). See the code for more clarity.
here is the code for refrence dry run it once https://ide.codingblocks.com/s/246111