#include #define REP(i, s, n) for (int i = s; i < n; i++) #define ALL(a) a.begin(), a.end() #define MOD 1000000007 using namespace std; typedef long long ll; int main() { int N, P; cin >> N >> P; vector A(N), B(N), C(N); REP(i, 0, N) cin >> A[i] >> B[i] >> C[i]; vector dp(P + 1, 1 << 30); dp[0] = 0; REP(i, 0, N) { for (int j = P; j >= 0; j--) { if (j + 1 <= P) dp[j + 1] = min(dp[j + 1], dp[j] + B[i]); if (j + 2 <= P) dp[j + 2] = min(dp[j + 2], dp[j] + C[i]); if (j + 3 <= P) dp[j + 3] = min(dp[j + 3], dp[j] + 1); dp[j] = dp[j] + A[i]; } // cout << "i : " << i << " : "; // REP(i, 0, P + 1) { // cout << setw(12) << setfill(' ') << dp[i]; // } // cout << endl; } cout << fixed << setprecision(15); cout << (double)dp[P] / N << endl; return 0; }