Skip to content

Instantly share code, notes, and snippets.

@modos
Created April 26, 2023 05:09
Show Gist options
  • Save modos/b294492e8a1a1735600ee972a58e04e3 to your computer and use it in GitHub Desktop.
Save modos/b294492e8a1a1735600ee972a58e04e3 to your computer and use it in GitHub Desktop.
مجموع جزئی
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