結果
問題 | No.155 生放送とBGM |
ユーザー | te-sh |
提出日時 | 2017-04-27 18:25:11 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2,301 ms / 6,000 ms |
コード長 | 1,115 bytes |
コンパイル時間 | 2,855 ms |
コンパイル使用メモリ | 155,940 KB |
実行使用メモリ | 54,812 KB |
最終ジャッジ日時 | 2024-06-12 18:58:01 |
合計ジャッジ時間 | 13,655 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
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 long[](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 long[][](l + 1, n); rt[0][0] = 1; foreach (i; 0..n-1) foreach_reverse (j; ti[i]..l+1) if (dp2[j - ti[i]] && dp2[j]) rt[j][1..$][] += rt[j - ti[i]][0..$-1][]; foreach (j; max(0, l-t)..l) dp1[] += rt[j][]; } 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; r += a; } foreach (j; 1..n+1) r /= j; writefln("%.10f", r); }