#include using namespace std; const int inf = 1e9; //template bool chmin(T& a,T b){if(a>b){a = b; return true;} return false;} //template bool chmax(T& a,T b){if(a> n >> p; vector a(n),b(n),c(n); for(int i=0; n>i; ++i) cin >> a[i] >> b[i] >> c[i]; //cost/val = 0/a[i],1/b[i],2/c[i],3/1 //dp[n][p] := n問まで見てcostpとなった時の順位の総和の最小値 int dp[n+1][p+1]; for(int i=0; n>=i; ++i){ for(int j=0; p>=j; ++j){ dp[i][j] = inf; } } dp[0][0] = 0; for(int i=0; n>i; ++i){ for(int j=0; p>=j; ++j){ dp[i+1][j+0] = min(dp[i+1][j+0],dp[i][j]+a[i]); if(j+1<=p) dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+b[i]); if(j+2<=p) dp[i+1][j+2] = min(dp[i+1][j+2],dp[i][j]+c[i]); if(j+3<=p) dp[i+1][j+3] = min(dp[i+1][j+2],dp[i][j]+1); } } double ans = double(dp[n][p])/double(n); cout << setprecision(15) << fixed << ans << endl; }