#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ALL(g) (g).begin(),(g).end() #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define F(i,j,k) fill(i[0],i[0]+j*j,k) #define P(p) cout<<(p)< right.c; } int n,p; //int dp[5001][15001]; int be[15001],af[15001]; int main(int argc, char const *argv[]) { cin >> n >> p; rep(i,3*n+1)be[i]=INF; be[p]=0; rep(i, n) { rep(j,3*n+1)af[j]=INF; int v[4]; rep(k, 3) cin >> v[k]; v[3] = 1; rep(j,p+1){ rep(k,4){ if(j>=k){ af[j-k]=min(af[j-k],be[j]+v[k]); } } } swap(be,af); } printf("%.10lf\n", be[0]/(double)n); return 0; }