#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair P; typedef vector V; typedef complex Point; #define PI acos(-1.0) #define EPS 1e-10 const ll INF = 1e16; const ll MOD = 1e9 + 7; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define rep(i,N) for(int i=0;i<(N);i++) #define ALL(s) (s).begin(),(s).end() #define EQ(a,b) (abs((a)-(b))> n >> p; rep(i,n){ cin >> C[i][0] >> C[i][1] >> C[i][2]; C[i][3] = 1; } rep(i,2)rep(j,3*5000+1)dp[i][j] = INF; rep(i,4)dp[1][i] = C[0][i]; FOR(i,1,n){ rep(j,p+1){ rep(k,4){ if(j+k <= p)dp[(i+1)%2][j+k] = min(dp[(i+1)%2][j+k],dp[i%2][j]+C[i][k]); } } } printf("%.10lf\n",(double)dp[n%2][p]/(double)n); }