想不到有什麼比較快的作法
while True: try: n,m=map(int,input().split()) a=list(map(int,input().split())) for v in range(m): x,y=map(int,input().split()) print(sum(a[x-1:y])) except: break
有人能提供想法嗎QQ
https://zerojudge.tw/ShowThread?postid=25101&reply=0