临时抱佛脚
简单树状数组模板
N = 100010
tr = [0 for i in range(N)]
a = [0 for i in range(N)]
def lowbit(x):
return -x&x
def add(x, c):
while x < N:
tr[x] += c
x += lowbit(x)
def query(x):
res = 0
while x:
res += tr[x]
x -= lowbit(x)
return res
n, m = map(int, input().split())
a[1:n+1] = list(map(int, input().split()))
for i in range(1, n+1):
add(i, a[i])
for i in range(m):
l, r = list(map(int, input().split()))
print(query(r)-query(l-1))
%%%%%%%55