結果

問題 No.155 生放送とBGM
ユーザー eitahoeitaho
提出日時 2015-02-18 01:56:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,801 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 77,356 KB
実行使用メモリ 10,916 KB
最終ジャッジ日時 2023-09-06 01:55:32
合計ジャッジ時間 7,225 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 887 ms
10,636 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 5 ms
4,828 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <climits>
#include <numeric>
#include <functional>
#include <time.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i <= (int)b; i++)
template<class T> void checkmin(T &a, T b) { if (b < a) a = b; }
template<class T> void checkmax(T &a, T b) { if (b > a) a = b; }

const int MaxN = 50;
const int MaxL = 300 * 60;
int N, L;
int Sec[MaxN];
ll dp[MaxN + 1][MaxL + 1];
int sumSec[MaxN];
double fact[MaxN + 1];


void solve() {
    sumSec[0] = 0;
    rep(i, N) sumSec[i + 1] = Sec[i + 1] + sumSec[i];
    fact[0] = 1;
    FOR(i, 1, N) fact[i] = fact[i - 1] * i;
    double ans = 0;

    rep(i, N) {
        rep(a, N + 1) rep(b, MaxL + 1) dp[a][b] = 0;
        dp[0][0] = 1;
        rep(other, N) if (other != i) {
            for (int used = other; used >= 0; used--) {
                for (int len = 0; len + Sec[other] <= MaxL; len++) {
                    dp[used + 1][len + Sec[other]] += dp[used][len];
                }
            }
        }
        double bad = 0;
        FOR(used, 1, N) FOR(len, L, MaxL) {
            bad += dp[used][len] * fact[used] * fact[N - used - 1] / fact[N];
        }
        ans += 1 - bad;
    }
    cout << ans << endl;
}

int main() {
    cin >> N >> L;
    L *= 60;
    rep(i, N) {
        string s;
        cin >> s;
        int sec = ((s[0] - '0') * 10 + s[1] - '0') * 60 + (s[3] - '0') * 10 + s[4] - '0';
        Sec[i] = sec;
    }
    solve();
    return 0;
}
0