#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif void solve() { 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(P + 1, 1e18); dp[0] = 0; for(int i = 0; i < N; i++) { vector ndp(P + 1, 1e18); for(int j = 0; j <= P; j++) { ndp[j] = min(ndp[j], dp[j] + A[i]); if(j + 1 <= P) ndp[j + 1] = min(ndp[j + 1], dp[j] + B[i]); if(j + 2 <= P) ndp[j + 2] = min(ndp[j + 2], dp[j] + C[i]); if(j + 3 <= P) ndp[j + 3] = min(ndp[j + 3], dp[j] + 1); } dp.swap(ndp); } cout << fixed << setprecision(16) << dp.back() / double(N) << "\n"; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }