import logging import sys from inspect import currentframe sys.setrecursionlimit(10 ** 6) input = sys.stdin.readline logging.basicConfig(level=logging.DEBUG) def dbg(*args): id2names = {id(v): k for k, v in currentframe().f_back.f_locals.items()} logging.debug( ", ".join(id2names.get(id(arg), "???") + " = " + repr(arg) for arg in args) ) def main(): INF = 10 ** 10 n, p = map(int, input().split()) a = [0] * n b = [0] * n c = [0] * n for i in range(n): a[i], b[i], c[i] = map(int, input().split()) dp = [[INF] * (p + 1) for _ in range(n + 1)] dp[0][0] = 0 for i in range(n): for j in range(p + 1): if j <= p: dp[i + 1][j] = min(dp[i][j] + a[i], dp[i + 1][j]) if j + 1 <= p: dp[i + 1][j + 1] = min(dp[i][j] + b[i], dp[i + 1][j + 1]) if j + 2 <= p: dp[i + 1][j + 2] = min(dp[i][j] + c[i], dp[i + 1][j + 2]) if j + 3 <= p: dp[i + 1][j + 3] = min(dp[i][j] + 1, dp[i + 1][j + 3]) # for i in range(n + 1): # dbg(dp[i]) ans = dp[n][p] / n print(ans) if __name__ == "__main__": main()