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())}) var dp = Array(P+1, { 0L }) val inf = 100000L*N val filled_dp = Array(P+1, { inf }) for (i in 0 until N) { val _dp = filled_dp.clone() for (k in Math.min(3*(i+1), P) downTo 3) { println(k) _dp[k] = arrayOf(dp[k]+q[i][0], dp[k-1]+q[i][1], dp[k-2]+q[i][2], dp[k-3]+1L).min()!! } if (P >= 2) _dp[2] = arrayOf(dp[2]+q[i][0], dp[1]+q[i][1], dp[0]+q[i][2]).min()!! if (P >= 1) _dp[1] = Math.min(dp[1]+q[i][0], dp[0]+q[i][1]) _dp[0] = dp[0]+q[i][0] dp = _dp } println(dp[P].toDouble() / N.toDouble()) }