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