Created
April 26, 2023 05:09
-
-
Save modos/b294492e8a1a1735600ee972a58e04e3 to your computer and use it in GitHub Desktop.
مجموع جزئی
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n, q = list(map(int, input().split(" "))) | |
A = list(map(int, input().split(" " ))); | |
ps = [0] * (n + 1) | |
for i in range(n): | |
ps[i + 1] = ps[i] + A[i]; | |
for i in range(q): | |
l, r = list(map(int, input().split(" "))) | |
r += 1 | |
print(ps[r] - ps[l]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment