結果

問題 No.155 生放送とBGM
ユーザー tsutajtsutaj
提出日時 2018-02-07 20:19:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,395 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 44,888 KB
実行使用メモリ 18,876 KB
最終ジャッジ日時 2023-10-18 22:32:47
合計ジャッジ時間 2,864 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 304 ms
18,820 KB
testcase_01 AC 289 ms
18,868 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 12 ms
13,584 KB
testcase_05 AC 2 ms
5,308 KB
testcase_06 AC 492 ms
18,776 KB
testcase_07 AC 3 ms
7,608 KB
testcase_08 AC 2 ms
5,380 KB
testcase_09 AC 4 ms
9,772 KB
testcase_10 AC 3 ms
7,448 KB
testcase_11 AC 4 ms
9,896 KB
testcase_12 AC 5 ms
9,856 KB
testcase_13 AC 3 ms
7,520 KB
testcase_14 AC 233 ms
18,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int N, L, S[60];
long long int dp[60][18010];
long long int dp2[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] = 1;
    for(int i=0; i<N; i++) {
        for(int j=i; j>=0; j--) {
            for(int k=0; k<=L; k++) {
                if(k - S[i] >= 0) dp[j+1][k] += dp[j][k - S[i]];
            }
        }
    }

    double ans = 0.0;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            for(int l=0; l<L; l++) {
                dp2[j][l] = dp[j][l];
                if(j > 0 && l-S[i] >= 0) dp2[j][l] -= dp2[j-1][l-S[i]];
                int pat = dp2[j][l];

                if(L-S[i]<=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