結果

問題 No.155 生放送とBGM
ユーザー りあんりあん
提出日時 2021-01-12 20:00:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,290 bytes
コンパイル時間 4,360 ms
コンパイル使用メモリ 204,500 KB
実行使用メモリ 32,168 KB
最終ジャッジ日時 2023-08-13 14:19:21
合計ジャッジ時間 10,338 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 886 ms
32,168 KB
testcase_01 AC 895 ms
31,880 KB
testcase_02 AC 881 ms
31,988 KB
testcase_03 AC 860 ms
31,948 KB
testcase_04 RE -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 845 ms
31,808 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 8 ms
5,200 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 10 ms
5,860 KB
testcase_12 AC 13 ms
5,800 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 639 ms
26,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;
using P = pair<int, int>;


int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(0);
    int n, l;
    scanf("%d%d", &n, &l);
    l *= 60;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        int x, y;
        scanf("%d:%d", &x, &y);
        a[i] = x * 60 + y;
    }
    vector<double> facts(n + 1);
    facts[0] = 1;
    for (int i = 1; i <= n; ++i) {
        facts[i] = facts[i - 1] * i;
    }
    int lim = l * 2 + 1;
    vector<vector<double>> dp(n + 1, vector<double>(lim));
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = n; j > 0; --j) {
            for (int k = lim; k >= a[i]; --k) {
                dp[j][k] += dp[j - 1][k - a[i]];
            }
        }
    }

    double ans = 0;
    for (int i = 0; i < n; ++i) {
        vector<vector<double>> dp2 = dp;
        for (int j = 1; j <= n; ++j) {
            for (int k = a[i]; k < lim; ++k) {
                dp2[j][k] -= dp2[j - 1][k - a[i]];
            }
        }
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k < l; ++k) {
                ans += dp2[j][k] * facts[j] * facts[n - j - 1];
            }
        }
    }
    cout << setprecision(16) << ans / facts[n] << '\n';
    return 0;
}
0