結果

問題 No.155 生放送とBGM
ユーザー te-shte-sh
提出日時 2017-04-28 12:02:26
言語 D
(dmd 2.107.1)
結果
WA  
実行時間 -
コード長 949 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 154,172 KB
実行使用メモリ 495,536 KB
最終ジャッジ日時 2023-09-03 13:05:10
合計ジャッジ時間 5,945 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 478 ms
493,096 KB
testcase_07 WA -
testcase_08 AC 4 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 4 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

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 dp = new long[][][](n + 1, l + 1, n + 1);
  dp[0][0][0] = 1;

  foreach (i; 0..n)
    foreach (j; 0..l+1) {
      dp[i+1][j][] = dp[i][j][];
      if (j >= si[i])
        dp[i+1][j][1..$][] += dp[i][j - si[i]][0..$-1][];
    }

  auto fact = new real[](n + 1);
  fact[0] = 1;
  foreach (i; 1..n+1)
    fact[i] = fact[i-1] * i;

  auto r = real(0);
  foreach (j; 0..n) {
    foreach (m; l-si[j]..l)
      foreach (k; 0..n) {
        auto a = dp[n][m][k];
        if (m - si[j] >= 0 && k > 0)
          a -= dp[n-1][m - si[j]][k-1];
        r += a * fact[k] * fact[n-k-1] * (k+1) / fact[n];
      }
  }

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