結果

問題 No.155 生放送とBGM
ユーザー mamekinmamekin
提出日時 2015-02-18 23:31:45
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,760 bytes
コンパイル時間 1,745 ms
コンパイル使用メモリ 103,540 KB
実行使用メモリ 722,332 KB
最終ジャッジ日時 2023-09-06 02:13:24
合計ジャッジ時間 12,789 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

void solve(const vector<int>& s, int len, vector<vector<vector<double> > >& dp)
{
    int n = s.size();
    dp.assign(n, vector<vector<double> >(n, vector<double>(len, 0.0)));
    dp[0][0][0] = 1.0;
    for(int i=0; i<n-1; ++i){
        for(int a=0; a<n-1; ++a){
            for(int b=0; b<len; ++b){
                dp[i+1][a][b] += dp[i][a][b];
                if(b + s[i] < len)
                    dp[i+1][a+1][b+s[i]] += dp[i][a][b];
            }
        }
    }
}

int main()
{
    int n, len;
    cin >> n >> len;
    len *= 60;

    vector<int> s(n);
    for(int i=0; i<n; ++i){
        int a, b;
        char c;
        cin >> a >> c >> b;
        s[i] = a * 60 + b;
    }

    vector<double> power(n, 1);
    for(int i=1; i<n; ++i)
        power[i] = power[i-1] * i;

    vector<vector<vector<double> > > dp1, dp2;
    solve(s, len, dp1);
    reverse(s.begin(), s.end());
    solve(s, len, dp2);

    double ret = 0.0;
    for(int i=0; i<n; ++i){
        for(int a=0; a<=i; ++a){
            for(int b=0; b<n-i; ++b){
                double tmp = 0.0;
                for(int j=len-1; j>=0; --j){
                    tmp += dp2[n-1-i][b][len-1-j];
                    ret += dp1[i][a][j] * tmp * power[a+b] * power[n-1-a-b];
                }
            }
        }
    }

    for(int i=1; i<=n; ++i)
        ret /= i;
    printf("%.10f\n", ret);

    return 0;
}
0