All Tracks Basic Programming Implementation Basics of Implementation Problem

Bahubali and Ausata
/
No tags
Problem
Editorial
Analytics

enter image description here

Once Rajmata is kidnapped by Bhallal Dev and Bahubali wants to free her but there is a problem. Rajmata is inside a room and to enter in the room ,Bahubali needs a secret code. There is a hint for the code and Bahubali is so frustrated that he can’t decode the hint so he asked you to help him.

Bhallal Dev gives Bahubali an array of size N and Q queries and for each queries he gives a range (Left to Right) to Bahubali.

As we know Bhallal Dev is a genious of mathematics so he defined a new keyword named AAUSATA .To find AAUSATA Bahubali has to find mean value of array between the given range.

Input:

First line contains two integers N and Q denoting number of array elements and number of queries.

Next line contains N space separated integers denoting array elements.

Next Q lines contain two integers L and R(indices of the array).

Output:

print a single integer denoting the value of AAUSATA.

Constraints :

1<= N ,Q,L,R <= 10^6

1<= Array elements <= 10^9

NOTE:

Use Fast I/O.

SAMPLE INPUT
5 3
1 2 3 4 5
1 3
2 4
2 5
SAMPLE OUTPUT
2 
3
3
Time Limit: 1.5 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?