#include using namespace std; #define DUMP(x) cerr << #x << "=" << x << endl #define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("< >(x) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define REP(i,m,n) for (int i=m;i<(int)(n);i++) #define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h)) #define ALL(a) (a).begin(),(a).end() typedef long long ll; const int INF = 1e9; const ll INFLL = 1e18; typedef pair PII; int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1}; const int MAX_M = 15001; ll dp[2][MAX_M]; int main() { ios::sync_with_stdio(false); int N, P; cin >> N >> P; fill(dp[0], dp[0] + 2 * 15001, INFLL); dp[0][0] = 0; rep(i, N) { int A[4]; rep(j, 3) cin >> A[j]; A[3] = 1; fill(dp[(i+1)&1], dp[(i+1)&1] + 15001, INFLL); rep(j, MAX_M) { rep(k, 4) { dp[(i+1)&1][j+k] = min(dp[(i+1)&1][j+k], dp[i&1][j] + A[k]); } } #ifdef DEBUG DUMP(dp[(i+1)&1][0]); #endif } cout << fixed << setprecision(10) << (dp[N&1][P] * 1.0 / N) << endl; }