#include #include #include #define repi(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,a) repi(i,0,a) #define all(a) (a).begin(), (a).end() constexpr int MAX_N = 5000; using ll = long long; constexpr ll INF = std::numeric_limits::max()>>2; ll N, P; ll a[3][MAX_N]; ll dp[2][15001]; void chmin( ll &a, ll b ) { a = std::min( a, b ); } int main() { scanf( "%lld%lld", &N, &P ); rep( i, N ) scanf( "%lld%lld%lld", &a[0][i], &a[1][i], &a[2][i] ); dp[0][P] = 0; rep( i, N ) { rep( j, P+1 ) dp[(i+1)%2][j] = INF; rep( j, P+1 ) { rep( k, 4 ) if( j-k >= 0 ) chmin( dp[(i+1)%2][j-k], dp[i%2][j]+(k==3?1:a[k][i]) ); } } printf( "%lf\n", (double)dp[N%2][0]/N ); return 0; }