题目描述
Problem Description
There are $ N $ fair 6-sided dice, and the $ j $th face ( $1 \leq j \leq 6$ ) of the $ i $th die ( $1 \leq i \leq N$ ) has an integer $ A_{i,j} $ written on it.
Takahashi repeats the operation of choosing one die and rolling it once. However, he stops the operation if, from the second roll onwards, the result is less than or equal to the result of the previous roll. He can choose which die to roll each time after seeing the result of the previous roll.
Takahashi wants to roll the dice as many times as possible. Find the expected number of operations when the selection is made to maximize the expected number of operations.
Input Format
The input is given from the standard input in the following format:
$ N $ $ A_{1,1} $ $ A_{1,2} $ $ A_{1,3} $ $ A_{1,4} $ $ A_{1,5} $ $ A_{1,6} $ $ A_{2,1} $ $ A_{2,2} $ $ A_{2,3} $ $ A_{2,4} $ $ A_{2,5} $ $ A_{2,6} $ $ : $ $ A_{N,1} $ $ A_{N,2} $ $ A_{N,3} $ $ A_{N,4} $ $ A_{N,5} $ $ A_{N,6} $
Output Format
Output the expected number of operations as a real number. The answer will be judged correct if the absolute or relative error with the judge's output is at most $ 10^{-6} $.
Sample Input and Output
Sample Input #1
2
1 2 3 4 5 6
7 8 9 10 11 12
Sample Output #1
3.64925355954377
Sample Input #2
3
12 237 374 111 247 234
857 27 98 65 83 90
764 60 999 11 7 4
Sample Output #2
3.42188884244970
Notes/Hints
Note
Discussion of this problem is prohibited until December 29, 2019, 05:00 JST. If mentioned, it may lead to claims for compensation.
It is okay to announce the total score and certification level after the test, but please do not disseminate information about which problems were solved.
Constraints
- $1 \leq N \leq 30,000$
- $1 \leq A_{i,j} \leq 10^9$
- All $ A_{i,j} $ are distinct.
- All values in the input are integers.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分