#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[5005][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 i = 0; i <= n; ++i) { for (ll j = 0; j <= p; ++j) { dp[i][j] = (1 << 30); } } dp[0][0] = 0; for (ll i = 0; i < n; ++i) { for (ll j = 0; j <= 3 * (i + 1); ++j) { if (j >= 3) { chmin(dp[i + 1][j], dp[i][j - 3] + 1); } if (j >= 2) { chmin(dp[i + 1][j], dp[i][j - 2] + c[i]); } if (j >= 1) { chmin(dp[i + 1][j], dp[i][j - 1] + b[i]); } chmin(dp[i + 1][j], dp[i][j] + a[i]); } } cout << fixed << setprecision(10) << static_cast(dp[n][p]) / n << endl; }