結果

問題 No.155 生放送とBGM
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2019-02-06 22:33:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,428 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 164,972 KB
実行使用メモリ 251,684 KB
最終ジャッジ日時 2023-09-05 06:41:55
合計ジャッジ時間 16,246 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2,304 ms
251,320 KB
testcase_04 WA -
testcase_05 AC 5 ms
13,312 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 13 ms
22,732 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 62 ms
52,292 KB
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/






int N, L, A[50];
double dp[2][51][301010];
double dp2[51][301010];
double fact[51];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> L;
    rep(i, 0, N) {
        int m, s;
        scanf("%d:%d", &m, &s);
        A[i] = m * 60 + s;
    }
    L *= 60;

    fact[0] = 1;
    rep(i, 1, 51) fact[i] = fact[i - 1] * i;

    dp[0][0][0] = 1;
    rep(i, 0, N) {
        int cur = i % 2;
        int nxt = 1 - cur;
        rep(cnt, 0, N + 1) rep(l, 0, 181818) {
            dp[nxt][cnt][l] = dp[cur][cnt][l];
            if (0 <= cnt - 1 and 0 <= l - A[i]) dp[nxt][cnt][l] += dp[cur][cnt - 1][l - A[i]];
        }
    }

    // dp[nxt][cnt][l] = dp[pre][cnt][l] + dp[pre][cnt-1][l-A[i]]
    // dp[pre][cnt][l] = dp[nxt][cnt][l] - dp[pre][cnt-1][l-A[i]]

    double ans = 0;
    rep(i, 0, N) {
        rep(cnt, 0, N + 1) rep(l, 0, 181818) {
            dp2[cnt][l] = dp[N%2][cnt][l];
            if (0 <= cnt - 1 and 0 <= l - A[i]) dp2[cnt][l] -= dp2[cnt - 1][l - A[i]];
        }
        rep(cnt, 0, N) rep(l, 0, L) ans += fact[cnt] * fact[N - cnt - 1] * dp2[cnt][l];
    }
    ans /= fact[N];

    printf("%.10f\n", ans);
}
0