#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); for (ll i = 0; i < n; ++i) { cin >> a[i] >> b[i] >> c[i]; } for (ll i = 0; i <= p; ++i) { for (ll j = 0; j <= n; ++j) { dp[j][i] = (1 << 30); } } dp[0][0] = 0; for (ll i = 0; i < n; ++i) { for (ll j = 0; j <= p; ++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; }