#C3438. Average Book Price Queries

    ID: 46865 Type: Default 1000ms 256MiB

Average Book Price Queries

Average Book Price Queries

You are given a list of books, where each book is represented by two numbers: its rating and its price. Then, you are given several queries. Each query specifies an inclusive range of ratings \(a\) to \(b\). For each query, compute the average price of all books whose ratings fall within the given range. If there are no books in the specified range, output 0.00. The average should be printed rounded to two decimal places.

The mathematical formula for the average price is given by:

\[ \text{Average Price} = \frac{\sum_{i=1}^{k} p_i}{k} \]

where \(p_i\) represents the prices of books with ratings within the range, and \(k\) is the count of such books.

inputFormat

The first line contains two integers \(n\) and \(q\) representing the number of books and the number of queries respectively. The next \(n\) lines each contain two integers: a book's rating and its price. The following \(q\) lines each contain two integers \(a\) and \(b\), representing a query for the range of ratings [\(a\), \(b\)].

outputFormat

Output \(q\) lines. For each query, print the average price of the books whose ratings are within the specified range, formatted to two decimal places. If no book fits in the range, print 0.00.

## sample
5 3
10 100
20 200
30 300
40 400
50 500
15 35
10 50
5 25
250.00

300.00 150.00

</p>