#include #include #pragma warning(disable : 4996) using namespace std; int n, p, a[5009], b[5009], c[5009], dp[15009]; int main() { scanf("%d%d", &n, &p); for (int i = 0; i < n; i++) scanf("%d%d%d", &a[i], &b[i], &c[i]); fill(dp + 1, dp + p + 1, 999999999); for (int i = 0; i < n; i++) { for (int j = min(3 * i, p); j >= 0; j--) { dp[j + 3] = min(dp[j + 3], dp[j] + 1); dp[j + 2] = min(dp[j + 2], dp[j] + c[i]); dp[j + 1] = min(dp[j + 1], dp[j] + b[i]); dp[j] += a[i]; } } printf("%.9lf\n", 1.0 * dp[p] / n); return 0; }