Starting from:

$25

Morning Problem: Call Centres

CMPUT 275 - Tangible Computing
Morning Problem: Call Centres
Description
You just became the manager of a call centre. There are many variables to take into account
to run an efficient call centre. To make these decisions, you need good data.
Your call centre is huge. Typically, many new calls are made every second. Your system logs each incoming call.
To get started with “data analytics”, you want to answer simple questions like the following: Between time s and time t, how many new calls were made to our call centre?
Input
The first line of input consists of two integers n and q. Here, 1 ≤ n ≤ 86, 400 is the number
of seconds your call centre is open for each day and 1 ≤ q ≤ 300, 000 is the number of queries
you want to make.
The next line contains n integers, each between 0 and 100. Consecutive integers will be
separated by a single space. The i’th integer on this line indicates how many new calls were
received by your call centre yesterday in the i’th second of operation.
Finally, q lines follow. Each consists of two integers 1 ≤ s ≤ t ≤ n separated by a single space.
Output
Output consists of q lines, one for each query. For each query with integers s, t, you should
output the total number of calls your call centre received yesterday between the s’th and
t’th second of operation (including the calls received exactly at second s and at second t).
Sample Input 1
13 7
5 3 13 0 0 1 4 3 12 1 0 0 17
1 3
1 4
1 13
3 3
4 4
2 7
8 11
Sample Output 1
21
21
59
13
0
21
16
Explanation for Some Queries
The first query is 1 3, which is asking how many calls were received between the 1st and
3th second of operation (inclusive). This is 5+3+13 = 21.
The second query is 1 4. There were 5+3+13+0 = 21 calls made between seconds 1 and 3.
The third query is 1 13, which is asking how many calls were made in total through all
13 seconds, which is 59.
The fourth query is 3 3: 13 calls were made during the 3rd second of operation.

More products