#include #include using namespace std; #define REP(i,n) for(int i=0;i<(int)(n);++i) #define CHMIN(a,b) a=min((a),(b)) #define CHMAX(a,b) a=max((a),(b)) int dp[2][15252]; int vs[5252][4]; const int INF = 1<<30; int main(){ int n,p; scanf("%d%d",&n,&p); REP(i,n)scanf("%d%d%d",vs[i]+0,vs[i]+1,vs[i]+2); fill(dp[0],dp[0]+p+1,INF); int cur = 0; dp[cur][0] = 0; REP(i,n){ vs[i][3] = 1; fill(dp[cur^1],dp[cur^1]+p+1,INF); REP(j,p+1){ CHMIN(dp[cur^1][j+0],dp[cur][j]+vs[i][0]); CHMIN(dp[cur^1][j+1],dp[cur][j]+vs[i][1]); CHMIN(dp[cur^1][j+2],dp[cur][j]+vs[i][2]); CHMIN(dp[cur^1][j+3],dp[cur][j]+vs[i][3]); } cur ^= 1; } printf("%.10f\n",(double)dp[cur][p] / n); return 0; }