結果
問題 | No.155 生放送とBGM |
ユーザー | te-sh |
提出日時 | 2017-04-27 18:22:11 |
言語 | D (dmd 2.107.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,107 bytes |
コンパイル時間 | 3,171 ms |
コンパイル使用メモリ | 155,100 KB |
実行使用メモリ | 55,704 KB |
最終ジャッジ日時 | 2023-09-03 13:04:50 |
合計ジャッジ時間 | 12,438 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,869 ms
55,312 KB |
testcase_01 | AC | 1,866 ms
55,508 KB |
testcase_02 | AC | 1,866 ms
55,452 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | AC | 348 ms
55,704 KB |
testcase_07 | AC | 6 ms
4,380 KB |
testcase_08 | AC | 3 ms
4,380 KB |
testcase_09 | AC | 11 ms
7,448 KB |
testcase_10 | AC | 3 ms
4,380 KB |
testcase_11 | AC | 13 ms
8,668 KB |
testcase_12 | AC | 14 ms
9,696 KB |
testcase_13 | AC | 4 ms
4,376 KB |
testcase_14 | AC | 1,368 ms
36,944 KB |
ソースコード
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; 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); }