#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ios std::ios_base::sync_with_stdio(false); #define ll long long #define pb push_back #define fi(ss) freopen (ss,"r",stdin) #define fo(ss) freopen (ss,"w",stdout) #define sz(v) ((int)((v).size())) #define all(x) (x).begin(),(x).end() #define REP(i, v) for(int i=0;i pii; typedef pair tri; int n,l; const int maxSum = 300 * 60 + 5; ll s[60]; double fac[60]; double dp1[maxSum][60]; double dp2[maxSum][60]; // set back dp int main() { fac[0] = 1; for (int i = 1 ; i < 60 ; ++i) { fac[i] = 1.0*i * fac[i - 1]; } scanf("%d %d",&n,&l); ll sum = 0; l*=60; int x,y; for (int i = 0 ; i < n ; ++i) { scanf("%d:%d",&x,&y); s[i]=x*60+y; sum+=s[i]; } if (l >= sum) { return printf("%d\n",n); } dp1[0][0] = 1; for (int i = 0 ; i < n ; ++i) { for (int j = i + 1; j >= 1 ; --j) { for (int cur = 0; cur <= l ; ++cur) { if (cur - s[i] >= 0) dp1[j][cur] += 1.0*dp1[j - 1][cur - s[i]]; } } } double ways = 0.0; for (int i = 0 ; i < n ; ++i) { for (int j = 0 ; j <= n ; ++j) { for (int cur = 0 ; cur <= l ;++cur) { dp2[cur][j] = dp1[cur][j]; if (cur == 0 && j == 0) dp2[cur][j] = 0; if (cur - s[i] >= 0 && j >= 1) { dp2[cur][j] -= dp2[cur - s[i]][j - 1]; } if (cur < l && cur + s[i] >= l) { ways += ((dp2[cur][j] * fac[j] * fac[n - j - 1])); } } } } printf("%.12f",ways / fac[n]); }