DMOPC '18 Contest 4 P1 - Dr. Henri and Differential Photometry

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Dr. Henri is looking through his telescope at the MRD Observatory. He is observing a certain star Y and wants to find its magnitude (a measure of brightness), mY. The magnitude of a star can be any real number.

Dr. Henri is using a device called a differential photometer to measure magnitude. Although this device is very precise, it cannot directly measure the magnitude of a star; it can only measure the difference in magnitudes between two stars.

Fortunately, Dr. Henri knows the magnitude mX of a certain star X. He decides to find mY by constructing a sequence of n+1 stars beginning with X and ending with Y. Then, for each star i on the list (except Y), he records the difference di=mi+1mi between the magnitudes of the stars i+1 and i, for a total of n observations. He can then calculate a value for mY from this sequence.

Dr. Henri knows that he must take multiple measurements in order to ensure accuracy, so he constructs K such sequences. Sequence i consists of ni observations, and the value of mY calculated from i is denoted as mYi. Of course, due to natural error in measuring, the mYi's calculated from each sequence may not be exactly the same. So Dr. Henri will use the mean of the mYi's, mY1+mY2++mYKK, as the final mY, which he denotes mYf.

Given K sequences of observations, please help Dr. Henri find mYf.

Constraints

2K1000
1ni1000
100.0mX,di100.0

Input Specification

The first line of input will contain one integer, K.
The second line will contain one real number, mX.
The next K lines will contain one integer ni, followed by ni space-separated real numbers di1,di2,,dini, the observations from the i-th list.

Output Specification

A single line containing one real number, mYf. Your answer will be judged as correct if it has an absolute error of no more than 103.

Sample Input

Copy
3
-1.46
2 4.53 1.20
3 4.77 -1.45 2.35
1 5.69

Sample Output

Copy
4.236667

Comments

There are no comments at the moment.