#include #include #include #include #include #include #include #include #include #include #include #include #include #define repd(i,a,b) for (int i=(a);i<(b);i++) #define rep(i,n) repd(i,0,n) #define var auto #define mod 1000000007 #define inf 2147483647 #define nil -1 typedef long long ll; using namespace std; int inputValue(){ int a; cin >> a; return a; } template void output(T a, int precision) { if(precision > 0){ cout << fixed << setprecision(precision) << a << "\n"; } else{ cout << a << "\n"; } } // end of template double fact[51]; double dp[51][36001]; double revdp[51][36001]; int main() { cin.tie(0); ios_base::sync_with_stdio(false); // source code // calculate n! fact[0] = 1; repd(i, 1, 51){ fact[i] = fact[i - 1] * i; } int N = inputValue(); // 50 int L = inputValue() * 60; // second 300 * 60 = 18000 vector S(N); // second // 00:01 ~ 59:59 int sum = 0; rep(i, N){ int m, s; scanf("%d:%d", &m, &s); S[i] = m * 60 + s; sum += S[i]; } if (sum <= L) { output(N, 0); return 0; } dp[0][0] = 1; rep(i, N){ for (int j = i; j >= 0; j--) { for (int k = 0; S[i] + k <= 2 * L; k++) { if (dp[j][k]){ dp[j + 1][min(2 * L, k + S[i])] += dp[j][k]; } } } } // 戻すDP double ret = 0; rep(i, N){ rep(j, N + 1){ for (int k = 0; k < L + S[i]; k++) { revdp[j][k] = dp[j][k]; if (k - S[i] >= 0 && j) revdp[j][k] -= revdp[j - 1][k - S[i]]; // if(revdp[j][k]) cout << "revdp[" << j << "][" << k << "] = " << revdp[j][k] << endl; if(N > j && k < L) ret += revdp[j][k] * fact[j] * fact[N - j - 1]; } } } // output(ret, 0); ret /= fact[N]; output(ret, 15); return 0; }