結果

問題 No.155 生放送とBGM
ユーザー tsutajtsutaj
提出日時 2018-02-07 19:57:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,627 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 45,268 KB
実行使用メモリ 695,224 KB
最終ジャッジ日時 2023-10-18 00:06:51
合計ジャッジ時間 4,955 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 73 ms
314,704 KB
testcase_05 AC 3 ms
7,432 KB
testcase_06 MLE -
testcase_07 AC 6 ms
24,008 KB
testcase_08 AC 4 ms
11,568 KB
testcase_09 AC 9 ms
36,404 KB
testcase_10 AC 5 ms
17,736 KB
testcase_11 AC 10 ms
38,552 KB
testcase_12 AC 11 ms
42,616 KB
testcase_13 AC 7 ms
28,048 KB
testcase_14 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int N, L, S[60];
long long int dp[60][60][18010];
long long int dp2[60][60][18010];

int main() {
    scanf("%d%d", &N, &L); L *= 60;

    int sum = 0;
    for(int i=0; i<N; i++) {
        int m, s; scanf("%d:%d", &m, &s);
        S[i] = 60*m + s;
        sum += S[i];
    }

    if(sum <= L) {
        printf("%.12f\n", (double)N);
        return 0;
    }

    dp[0][0][0] = 1;
    for(int i=0; i<N; i++) {
        int cur = i, nxt = i+1;
        for(int j=0; j<=i; j++) {
            for(int k=0; k<=L; k++) {
                dp[nxt][j][k] += dp[cur][j][k];
                if(k - S[i] >= 0) dp[nxt][j+1][k] += dp[cur][j][k - S[i]];
            }
        }
    }

    for(int i=0; i<N; i++) {
        dp2[i][0][0] = 1;
        int cur = N, pre = cur-1;
        for(int j=1; j<N; j++) {
            for(int k=0; k<=L; k++) {
                dp2[i][j][k] = dp[cur][j][k];
                if(k-S[i] >= 0) dp2[i][j][k] -= dp2[i][j-1][k-S[i]];
            }
        }
    }

    double ans = 0.0;
    for(int i=0; i<N; i++) {
        for(int l=max(0, L-S[i]); l<L; l++) {
            for(int j=0; j<N; j++) {
                long long int pat = dp2[i][j][l];
                int X = j, Y = N-j-1;

                // combination
                double b = 1;
                for(int k=1; k<=min(X,Y); k++) {
                    b *= (N - k);
                    b /= k;
                }
                b *= N;
                b = ((X+1) * pat) / b;
                ans += b;
            }
        }
    }
    printf("%.12f\n", ans);
    return 0;
}
0