結果
問題 | No.155 生放送とBGM |
ユーザー | paruki |
提出日時 | 2016-09-06 14:17:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 143 ms / 6,000 ms |
コード長 | 1,690 bytes |
コンパイル時間 | 1,655 ms |
コンパイル使用メモリ | 171,700 KB |
実行使用メモリ | 21,000 KB |
最終ジャッジ日時 | 2024-11-15 20:34:17 |
合計ジャッジ時間 | 3,170 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<<endl #define smax(x,y) (x)=max((x),(y)) #define smin(x,y) (x)=min((x),(y)) #define MEM(x,y) memset((x),(y),sizeof (x)) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vll; template <class Val> vector<Val> factorials(int n){ vector<Val> res(n + 1); res[0] = res[1] = 1; for(int i = 2; i <= n; ++i) res[i] = res[i - 1] * i; return res; } int N, L; const int HI = 300 * 60 + 60 * 60 + 1; double adp[HI][51], bdp[HI][51]; int main(){ cin >> N >> L; L *= 60; vi S(N); int sm = 0; rep(i, N){ int m, s; scanf("%d:%d", &m, &s); S[i] = m * 60 + s; sm += S[i]; } if(sm <= L){ cout << N << endl; return 0; } adp[0][0] = 1; rep(i, N){ for(int t = L+S[i]-1; t >= S[i]; --t){ for(int x = i+1; x >= 1; --x){ adp[t][x] += adp[t - S[i]][x - 1]; } } } auto F = factorials<double>(N); double ans = 0; rep(i, N){ rep(t, L + S[i]){ rep(x, N + 1){ bdp[t][x] = adp[t][x]; if(t >= S[i] && x > 0){ bdp[t][x] -= bdp[t - S[i]][x - 1]; } if(t < L && x<N)ans += bdp[t][x] * F[x] * F[N - x - 1]; } } } ans /= F[N]; cout << setprecision(20) << ans << endl; }