結果

問題 No.155 生放送とBGM
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2019-02-06 22:36:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,013 ms / 6,000 ms
コード長 2,437 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 164,772 KB
実行使用メモリ 262,780 KB
最終ジャッジ日時 2023-09-05 06:50:19
合計ジャッジ時間 17,456 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,013 ms
262,516 KB
testcase_01 AC 1,988 ms
262,656 KB
testcase_02 AC 2,001 ms
262,632 KB
testcase_03 AC 2,000 ms
262,632 KB
testcase_04 AC 728 ms
178,160 KB
testcase_05 AC 5 ms
13,364 KB
testcase_06 AC 1,990 ms
262,780 KB
testcase_07 AC 27 ms
35,864 KB
testcase_08 AC 13 ms
22,668 KB
testcase_09 AC 45 ms
46,720 KB
testcase_10 AC 18 ms
30,268 KB
testcase_11 AC 45 ms
46,716 KB
testcase_12 AC 57 ms
52,408 KB
testcase_13 AC 34 ms
41,460 KB
testcase_14 AC 1,769 ms
250,240 KB
権限があれば一括ダウンロードができます

ソースコード

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() {
    scanf("%d %d", &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