Range Sum Queries

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

You are given N integers and Q queries.

The N integers, stored in an array, will be 1-indexed.

The query format will be: a b, asking the for the sum of arr[a] to arr[b].

Input Specification

The first line will contain an integer N (1 \le N \le 100).

The next line will contain N integers a_i (-1000 \le a_i \le 1000).

The third line of input will contain Q (1 \le Q \le 10).

The next Q lines will contain integers a and b (1 \le a \le b \le 100).

Output Specification

There will be Q lines of output, each answering the query of a b.

Sample Input 1

5
1 2 3 6 5
4
1 2
3 4
5 5
1 5

Sample Output 1

3
9
5
17

Comments

There are no comments at the moment.