結果

問題 No.155 生放送とBGM
ユーザー te-shte-sh
提出日時 2018-07-12 17:05:26
言語 D
(dmd 2.107.1)
結果
MLE  
実行時間 -
コード長 1,289 bytes
コンパイル時間 3,249 ms
コンパイル使用メモリ 153,372 KB
実行使用メモリ 733,728 KB
最終ジャッジ日時 2023-09-03 20:42:14
合計ジャッジ時間 9,578 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 RE -
testcase_06 MLE -
testcase_07 AC 4 ms
5,824 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 7 ms
9,372 KB
testcase_10 AC 2 ms
4,956 KB
testcase_11 AC 10 ms
12,548 KB
testcase_12 AC 11 ms
13,268 KB
testcase_13 AC 3 ms
5,356 KB
testcase_14 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, l; readV(n, l);
  string[] st; readA(n, st);

  l *= 60;
  auto s = st.map!(sti => sti[0..2].to!int*60+sti[3..5].to!int).array;

  if (s.sum < l) {
    writeln(n);
    return;
  }

  auto dp1 = new long[][][](n+1, n+1, l); dp1[0][0][0] = 1;
  foreach (i; 0..n)
    foreach (j; 0..n+1)
      foreach (k; 0..l) {
        dp1[i+1][j][k] = dp1[i][j][k];
        if (j >= 1 && k >= s[i])
          dp1[i+1][j][k] += dp1[i][j-1][k-s[i]];
      }

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

  auto r = 0.0L;
  foreach (i; 0..n) {
    auto dp2 = new long[][](n+1, l);
    foreach (j; 0..n+1)
      foreach (k; 0..l) {
        dp2[j][k] = dp1[n][j][k];
        if (j >= 1 && k >= s[i])
          dp2[j][k] -= dp2[j-1][k-s[i]];
      }

    foreach (j; 0..n)
      foreach (k; l-s[i]..l)
        r += dp2[j][k]*fact[j+1]*fact[n-1-j];
  }

  writefln("%.10f", r/fact[n]);
}
0