using namespace std;
int main()
{
int S,N,M,Q,R;
static int Narr[100001];
cin >> S;
for (int i = 0; i < S; i++)
{
cin >> N >> M;
for (int j = 0; j < N; j++)
cin >> Narr[j];
for (int j = 0; j < M; j++)
{
long long sum = 0;
cin >> Q >> R;
for (int k = Q; k <= R; k++)
sum += Narr[k - 1];
cout << sum << endl;
}
}
//system("pause");
return 0;
}
沒有留言:
張貼留言