import java.util.* fun main(args: Array) { val sc = Scanner(System.`in`) val (N, P) = Pair(sc.nextInt(), sc.nextInt()) val q = Array(N, { arrayOf(sc.nextInt(), sc.nextInt(), sc.nextInt() )}) val inf = 100000L*N val dp = Array(P+4, { i -> if (i == 3) 0L else inf }) for (i in 0 until N) { for (dest in Math.min(3*i+6, P+3) downTo 3) { dp[dest] = arrayOf(dp[dest]+q[i][0], dp[dest-1]+q[i][1], dp[dest-2]+q[i][2], dp[dest-3]+1).min()!! } } println(dp[P+3].toDouble() / N.toDouble()) }