#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n) - 1; i >= 0; i--) #define reps(i, n) for (int i = 1; i <= (n); i++) #define repi(i, a, b) for (int i = (a); i < (b); i++) #define all(a) (a).begin(), (a).end() #define bit(b) (1ull << (b)) using namespace std; using i32 = long long; using u32 = unsigned long long; using i64 = long long; using u64 = unsigned long long; using f64 = double; using vi32 = vector; using vu32 = vector; using vi64 = vector; using vu64 = vector; using vf64 = vector; using vstr = vector; using vvi32 = vector; using vvu32 = vector; using vvi64 = vector; using vvu64 = vector; using vvf64 = vector; template void amax(T &x, S y) { if (x < y) x = y; } template void amin(T &x, S y) { if (y < x) x = y; } int n, p; class Rank { public: int a, b, c; }; vector abc; i64 memo[5010][15010]; i64 rec(int i, int j) { if (memo[i][j]) return memo[i][j]; if (j < 0 || j > (n - i) * 3) return 1e9; if (i == n) return 0; i64 ret = 1 + rec(i + 1, j - 3); amin(ret, abc[i].a + rec(i + 1, j)); amin(ret, abc[i].b + rec(i + 1, j - 1)); amin(ret, abc[i].c + rec(i + 1, j - 2)); return memo[i][j] = ret; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(16); cin >> n >> p; rep(i, n) { int a, b, c; cin >> a >> b >> c; abc.push_back({a, b, c}); } cout << rec(0, p) / (f64) n << endl; return 0; }