#include #include using namespace std; #define FOR(i, a, n) for(int i=a; i=a; i--) #define REP(i, n) FOR(i, 0, n) #define RREP(i, n) RFOR(i, 0, n) #define INF 10000000 int dp_from[15001]; int dp_to[15001]; int main() { int N, P; int a[5001], b[5001], c[5001]; cin >> N >> P; REP(i, N) cin >> a[i] >> b[i] >> c[i]; REP(i, 3 * N + 1) dp_from[i] = INF; dp_from[P] = 0; REP(i, N) { REP(j, 3 * N + 1) dp_to[j] = INF; REP(j, P + 1) { if (j >= 3) dp_to[j - 3] = min(dp_to[j - 3], dp_from[j] + 1); if (j >= 2) dp_to[j - 2] = min(dp_to[j - 2], dp_from[j] + c[i]); if (j >= 1) dp_to[j - 1] = min(dp_to[j - 1], dp_from[j] + b[i]); dp_to[j] = min(dp_to[j], dp_from[j] + a[i]); } swap(dp_from, dp_to); } printf("%.6lf\n", dp_from[0] * 1.0 / N); return 0; }