結果

問題 No.155 生放送とBGM
ユーザー te-shte-sh
提出日時 2017-04-27 17:42:12
言語 D
(dmd 2.107.1)
結果
MLE  
実行時間 -
コード長 1,122 bytes
コンパイル時間 2,253 ms
コンパイル使用メモリ 154,552 KB
実行使用メモリ 825,524 KB
最終ジャッジ日時 2023-09-03 13:03:40
合計ジャッジ時間 12,554 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 int[](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 int[][](l + 1);
    rt[0] = [0];
    foreach (i; 0..n-1)
      foreach_reverse (j; ti[i]..l+1)
        if (dp2[j - ti[i]] && dp2[j])
          rt[j] ~= rt[j - ti[i]].map!"a + 1".array;

    foreach (j; l-t..l)
      foreach (r; rt[j])
        ++dp1[r];
  }

  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;
    foreach (j; 1..n+1) a /= j;
    r += a;
  }

  writefln("%.10f", r);
}
0