#K71337. Calculate Task Averages

    ID: 33509 Type: Default 1000ms 256MiB

Calculate Task Averages

Calculate Task Averages

You are given an array tasks consisting of n integers, where each integer represents the number of tasks completed by a user. You are also given q queries. Each query is a pair of integers x and y (0-indexed) representing an interval of users. For each query, you should compute the average number of tasks completed in the range from index x to index y inclusive.

The average is computed using the formula:

$$\text{average} = \frac{\sum_{i=x}^{y} {\rm tasks}[i]}{y - x + 1}$$

Your result for each query should be formatted as a floating point number with exactly two decimal places.

inputFormat

The input is read from standard input (stdin) and has the following format:

n q
tasks[0] tasks[1] ... tasks[n-1]
x1 y1
x2 y2
... 
Xq Yq

Here, the first line contains two integers n (the number of users) and q (the number of queries). The second line contains n integers, each representing the number of tasks completed by each user. The next q lines each contain two integers x and y (with 0 ≤ x ≤ y < n) representing the range of indices for a query.

outputFormat

For each query, print the average number of tasks completed (formatted with two decimal places) on a new line to standard output (stdout).

## sample
5 3
10 20 30 40 50
0 2
1 3
2 4
20.00

30.00 40.00

</p>