问题1724--candy

1724: candy

时间限制: 3Sec 内存限制:128 MB
提交:500 解决:118
[ 状态] [ 讨论版] [ 提交] [命题人: ]
题目描述

Kimi has a lot of candies, and divides them into piles, where theith pile containsAicandies. Each time Kimi will choose an interval[l,r], and calculate the total amount ofAl,Al+1,…,Ar. It's a hard task, and you're required to solve it.

输入

An integerT(T≤10)will exist in the first line of input, indicating the number of test cases. Each test case begins with the number of pilesN(1≤N≤105). The second line containsNintegersAi(1≤Ai≤100), whereAistands for the number of candies in theith pile. The next line is the number of queriesM(1≤M≤105). The nextMlines, each with two integersl,r(1≤lrN), describe the queried intervals.

输出

For each test case, output the total amount of candies in the queried interval.

样例输入 Copy
1 5 1 2 4 5 9 3 1 2 2 4 4 5
样例输出 Copy
3 11 14
来源/分类