Problem G
Tai's formula

Can you, just like Tai, reinvent the wheel and calculate the area under a glucose curve? Instead of publishing a paper, you need to implement the algorithm. You need this algorithm in your new app, that logs your glucose values that comes from a continuous glucose monitor. You have also figured out the trick of the device. It’s not actually continuous, it just samples the glucose value frequently, automatically.
Input
Input contains several lines of numbers separated by spaces.
The first line contains the integer
The following
Each line contains two numbers
The glucose values
Each glucose value is given with exactly one decimal digit.
Since you are working with a computer program, the time of
each sample is given as an integer, the number of milliseconds
since the first of January
The samples are always given in increasing order by time,
meaning
Note that a second is a thousand milliseconds.
Output
The area under the glucose curve in the unit
Answers within a relative or absolute error of
Sample Explanation
In Sample Input
Sample Input 1 | Sample Output 1 |
---|---|
3 1000 2.0 2000 12.0 3000 22.0 |
24 |
Sample Input 2 | Sample Output 2 |
---|---|
3 1000 4.0 2000 8.0 3001 7.3 |
13.65765 |