#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long double ld; typedef long long ll; typedef vector vint; typedef pair pii; typedef pair pll; typedef pair pdd; typedef complex compd; #define rep(i,n) for(int i=0;i=0;i--) #define RREP(i,n) for(int i=n;i>=0;i--) #define all(a) (a).begin(),(a).end() #define mp(a,b) make_pair(a,b) #define mt make_tuple #define fst first #define scn second #define bicnt(x) __buildin__popcount(x) #define debug(x) cout<<"debug: "<> n >> p; REP(i, n) REP(j, p) dp[i][j] = inf; dp[0][0] = 0; rep(i, n) { int a, b, c; cin >> a >> b >> c; REP(j, p) { if (dp[i][j] == inf) continue; dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + a); if (j + 1 <= p) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + b); if (j + 2 <= p) dp[i + 1][j + 2] = min(dp[i + 1][j + 2], dp[i][j] + c); if (j + 3 <= p) dp[i + 1][j + 3] = min(dp[i + 1][j + 3], dp[i][j] + 1); } } REP(i, n) { REP(j, n) cout << dp[i][j] << " "; cout << endl; } printf("%.15Lf\n", ((ld)dp[n][p]) / ((ld)n) + eps); return 0; }