#include using namespace std; int main() { int N, P; cin >> N >> P; int a[N], b[N], c[N]; int i, j, k; for(i = 0; i < N; i++) { cin >> a[i] >> b[i] >> c[i]; } int dp[N + 1][P + 1]; //N個目までのコンテストでP問解答した時の順位の和 for(i = 0; i <= N; i++) { for(j = 0; j <= P; j++) { dp[i][j] = 1000000.0; } } dp[0][0] = 0; for(i = 0; i < N; i++) { for(j = 0; j <= P; j++) { dp[i + 1][j] = dp[i][j] + a[i]; if(j>0)dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - 1] + b[i]); if(j>1)dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - 2] + c[i]); if(j>2)dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - 3] + 1); } } printf("%.6f\n",(double)dp[N][P] / N); return 0; }