Andyman's Golf Course - Hole 3 - Prefix Sum Array

View as PDF

Submit solution


Points: 0
Time limit: 6.0s
Memory limit: 1G

Author:
Problem type
Allowed languages
Python

For the third hole of AndyMan68's golf course, he would like you to simply build a prefix sum array and handle range sum queries on it.

Input Specification

The first line will contain a list of spaced positive integers.

The next line will contain Q, the number of range sum queries.

The next Q lines will contain 2 spaced integers, l and r, indicating the bounds for the range some query (l\le r).

It is guaranteed that l and r will be between 1 and the length of the list of integers inclusive.

The length of the list of integers will not exceed 10^5 and the number of queries will not exceed 10^5. The integers in the list will not exceed 100.

Output Specification

For each query, output the sum of the integers from the l-th number to r-th number inclusive.

Scoring

If the program has the correct output, you will receive a score of (for each test case)

  • 0 if the length of the code in bytes exceeds 200
  • 100 if the length of the code in bytes is less than 115
  • (215-N)\times \frac{115}{N} where N is the length of code in bytes, if 115\le N \le200

Sample Input 1

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

Sample Output 1

10
9
15

Comments

There are no comments at the moment.