#include using namespace std; using ll = long long; template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; } constexpr ll inf = (1LL << 62); int dp[15005]; int main() { ll n, p; cin >> n >> p; vector a(n), b(n), c(n); //vector> dp(n + 1, vector(p + 1, (1 << 30))); for (ll i = 0; i < n; ++i) { cin >> a[i] >> b[i] >> c[i]; } for (ll j = 0; j < 15005; ++j) { dp[j] = (1 << 30); } dp[0] = 0; for (ll i = 0; i < n; ++i) { for (ll j = 3 * (i + 1); j >= 0; --j) { dp[j] = dp[j] + a[i]; if (j >= 3) { chmin(dp[j], dp[j - 3] + 1); } if (j >= 2) { chmin(dp[j], dp[j - 2] + c[i]); } if (j >= 1) { chmin(dp[j], dp[j - 1] + b[i]); } //for (ll t = 0; t < 4; ++t) { // cout << dp[t] << endl; //} } } cout << fixed << setprecision(10) << static_cast(dp[p]) / n << endl; }