There is an array of n numbers and after m number of steps, one needs to answer the query. In every step from 1 to m, we calculate the cumulative sum. Then queries are asked, which index contains which number in the array.
For example, if n = 5, m = 3, the array = 2,4,3,9,1
we conduct the m steps.
If the query is 2, the answer will be 25.
How can I solve this problem?
N.B: It just came to my mind. I didn't find any such problem in any OJ. If you can, please provide the link. And sorry for bad english.