import numpy as np

N,P = map(int,input().split())

data = np.array([list(map(int,input().split())) for _ in range(N)])

dp = np.zeros((N+1,P+1),int)
dp[1,:min(3,P+1)] = data[0,:min(3,P+1)]
dp[1:,0] = [data[:i,0].sum() for i in range(1,N+1)]

for i in range(N):
    for j in range(1,P+1):
        tmp = []
        if dp[i,j]!=0:tmp.append(dp[i,j]+data[i,0])
        if j-1>=0 and dp[i,j-1]!=0:tmp.append(dp[i,j-1]+data[i,1])
        if j-2>=0 and dp[i,j-2]!=0:tmp.append(dp[i,j-2]+data[i,2])
        if tmp:dp[i+1,j] = min(tmp)
print(min(1.,dp[:,P].min()/N))