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

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), m_Y. 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 m_X of a certain star X. He decides to find m_Y 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 d_i = m_{i + 1} - m_i between the magnitudes of the stars i + 1 and i, for a total of n observations. He can then calculate a value for m_Y 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 n_i observations, and the value of m_Y calculated from i is denoted as m_{Yi}. Of course, due to natural error in measuring, the m_{Yi}'s calculated from each sequence may not be exactly the same. So Dr. Henri will use the mean of the m_{Yi}'s, \frac{m_{Y1} + m_{Y2} + \ldots + m_{YK}}{K}, as the final m_Y, which he denotes m_{Yf}.

Given K sequences of observations, please help Dr. Henri find m_{Yf}.


2 \leq K \leq 1\ 000
1 \leq n_i \leq 1\ 000
-100.0 \leq m_X, d_i \leq 100.0

Input Specification

The first line of input will contain one integer, K.
The second line will contain one real number, m_X.
The next K lines will contain one integer n_i, followed by n_i space-separated real numbers d_{i1}, d_{i2}, \ldots, d_{in_i}, the observations from the i-th list.

Output Specification

A single line containing one real number, m_{Yf}. Your answer will be judged as correct if it has an absolute error of no more than 10^{-3}.

Sample Input

2 4.53 1.20
3 4.77 -1.45 2.35
1 5.69

Sample Output



There are no comments at the moment.