Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
469 B
3
Indexable
Never
# your code goes here
t = int(input())
for i in range(t):
    nums = list(map(int,input().split()))

    csum = [nums[0]]
    for i in range(1,len(nums)):
        csum.append(nums[i]+csum[-1])
    def find_csum(query):
        if query[0] == 0:
            return csum[query[1]]
        return(csum[query[1]]-csum[query[0]-1])
    q = int(input())
    for i in range(q):
        query = list(map(int,input().split()))
        print(find_csum(query))
            

    
Leave a Comment