Loading...
Loading...
Loading...
A shop records its sales for n days, numbered from 0. For each query, print the total sales from day l to day r, both days included.
Example
Input
5 3 1 4 1 5 2 0 2 1 4
Output
8 11
Items 0 to 2 add to 8. Items 1 to 4 add to 11.
Try the problem first. Open one hint at a time.
Adding the range for every query repeats work. Build the running totals once.
With a leading 0, the answer is prefix[r + 1] - prefix[l].
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor