#include using namespace std; signed main() { ios::sync_with_stdio(false); int n, p; cin >> n >> p; vector a(n), b(n), c(n); for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i] >> c[i]; } vector> dp(2, vector(p + 1, 0x3f3f3f3f)); dp[0][0] = 0; for (int i = 0; i < n; ++i) { dp[~i & 1] = vector(p + 1, 0x3f3f3f3f); for (int j = 0; j <= p; ++j) { dp[~i & 1][j] = min(dp[~i & 1][j], dp[i & 1][j] + a[i]); if (j + 1 <= p) { dp[~i & 1][j + 1] = min(dp[~i & 1][j + 1], dp[i & 1][j] + b[i]); } if (j + 2 <= p) { dp[~i & 1][j + 2] = min(dp[~i & 1][j + 2], dp[i & 1][j] + c[i]); } if (j + 3 <= p) { dp[~i & 1][j + 3] = min(dp[~i & 1][j + 3], dp[i & 1][j] + 1); } } } cout << fixed << setprecision(7) << (1.0 * dp[n & 1][p] / n) << endl; return 0; }