結果

問題 No.155 生放送とBGM
ユーザー eitahoeitaho
提出日時 2015-02-18 20:42:40
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,761 bytes
コンパイル時間 597 ms
コンパイル使用メモリ 76,816 KB
実行使用メモリ 141,744 KB
最終ジャッジ日時 2023-09-06 02:06:28
合計ジャッジ時間 22,766 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 * MaxN + 1];
int sumSec[MaxN];
double fact[MaxN + 1];


void solve() {
    rep(i, N) sumSec[i] = Sec[i] + (i > 0 ? sumSec[i - 1] : 0);
    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, sumSec[N - 1] + 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] <= sumSec[other]; len++) {
                    dp[used + 1][len + Sec[other]] += dp[used][len];
                }
            }
        }
        double bad = 0;
        FOR(used, 1, N - 1) FOR(len, L, sumSec[N - 1]) {
            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) {
        int m, s;
        scanf("%d:%d", &m, &s);
        Sec[i] = m * 60 + s;
    }
    solve();
    return 0;
}
0