#include #include #include #define INF (1<<30) using namespace std; int n,p,a[5001],b[5001],c[5001]; double dp[5001][15001],ans;//iコンテストまでにj解いた時の平均順位の最低値 int main(){ cin>>n>>p; for(int i=1;i<=n;i++){ cin>>a[i]>>b[i]>>c[i]; } for(int i=1;i<=n;i++){ for(int j=0;j<=3*i;j++){ if(j==0){ dp[i][j]=(dp[i-1][j]+a[i]); } else if(j==1){ dp[i][j]=min((dp[i-1][0]+b[i]),(dp[i-1][1]+a[i])); } else if(j==2){ dp[i][j]=min(min((dp[i-1][0]+c[i]),(dp[i-1][1]+b[i])),(dp[i-1][2]+a[i])); } else if(j==3*i){ dp[i][j]=(dp[i-1][j-3]+1); } else if(j==3*i-1){ dp[i][j]=min((dp[i-1][j-3]+1),(dp[i-1][j-2]+c[i])); } else if(j==3*i-2){ dp[i][j]=min(min((dp[i-1][j-3]+1),(dp[i-1][j-2]+c[i])),(dp[i-1][j-1]+b[i])); } else{ dp[i][j]=min(min(min(dp[i-1][j-3]+1,dp[i-1][j-2]+c[i]),dp[i-1][j-1]+b[i]),dp[i-1][j]+a[i]); } } } ans=(double)dp[n][p]/n; printf("%.10f\n",ans); return 0; }