LogiQuest

344. Waiting Time at a Counter

MediumSimulation

Customers arrive at times a[i] (non-decreasing) and need s[i] minutes at a single counter, served in arrival order. Print the average waiting time (time between arrival and start of service) with 2 decimal places.

Input format

Line 1: n Next n lines: arrival service

Output format

The average wait.

Example 1

Input

3
0 3
1 9
2 6

Output

4.00

Example 2

Input

1
5 5

Output

0.00

Constraints

1 ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.

Loading the MyLoginn IDE…