#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define CLR(mat) memset(mat, 0, sizeof(mat)) typedef long long ll; int from[15005], to[15005]; // := i+1日めで正解数がjの時の順位の和の最小 int main() { ios::sync_with_stdio(false); cin.tie(0); int N, P; cin >> N >> P; FOR(j,0,15005) from[j] = to[j] = 2e9; from[0] = 0; int a[N], b[N], c[N]; FOR(i,0,N) cin >> a[i] >> b[i] >> c[i]; FOR(i,0,N) { FOR(j,0,P+1) to[j] = 2e9; FOR(j,0,P+1) { // 0問 to[j] = min(to[j],from[j]+a[i]); // 1問 if(j+1<=P) to[j+1] = min(to[j+1],from[j]+b[i]); // 2問 if(j+2<=P) to[j+2] = min(to[j+2],from[j]+c[i]); // 3問 if(j+3<=P) to[j+3] = min(to[j+3],from[j]+1); } swap(from,to); } cout << fixed << setprecision(17) << (double)from[P] / N << endl; return 0; }