n, p = map(int, input().split()) dp = [1 << 30] * (p + 1) dp[0] = 0 for _ in range(n): a, b, c = map(int, input().split()) for i in range(p, -1, -1): mi = dp[i] + a if i >= 1: mi = min(mi, dp[i - 1] + b) if i >= 2: mi = min(mi, dp[i - 2] + c) if i >= 3: mi = min(mi, dp[i - 3] + 1) dp[i] = mi print(dp[-1] / n)