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 var dp = Array(P+4, { inf }) dp[3] = 0 val dp2 = Array(P+4, { inf }) for (i in 0 until N) { val _dp = dp2.clone() for (dest in Math.min(3*i+6, P+3) downTo 3) { _dp[dest] = Math.min(Math.min(Math.min(dp[dest]+q[i][0], dp[dest-1]+q[i][1]), dp[dest-2]+q[i][2]), dp[dest-3]+1) } dp = _dp } println(dp[P+3].toDouble() / N.toDouble()) }