import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.bitmanip; // BitArray void main() { auto rd = readln.split.to!(int[]), n = rd[0], l = rd[1] * 60; auto si = readln.split.map!(s => s[0..2].to!int * 60 + s[3..5].to!int).array; if (l >= si.sum) { writeln(n); return; } auto dp1 = new int[](n); auto calc(int t, int[] ti) { auto dp2 = BitArray(); dp2.length = l + 1; dp2[0] = true; foreach (i; 0..n-1) { auto a = dp2.dup; a <<= ti[i]; dp2 |= a; } auto rt = new int[][](l + 1); rt[0] = [0]; foreach (i; 0..n-1) foreach_reverse (j; ti[i]..l+1) if (dp2[j - ti[i]] && dp2[j]) rt[j] ~= rt[j - ti[i]].map!"a + 1".array; foreach (j; l-t..l) foreach (r; rt[j]) ++dp1[r]; } foreach (i; 0..n) { auto t = si[i], ti = si[0..i] ~ si[i+1..n]; calc(t, ti); } real r = 0; foreach (i; 0..n) { auto a = dp1[i].to!real * (i + 1); foreach (j; 1..i+1) a *= j; foreach (j; 1..n-i) a *= j; foreach (j; 1..n+1) a /= j; r += a; } writefln("%.10f", r); }