結果

問題 No.155 生放送とBGM
ユーザー mamekinmamekin
提出日時 2015-02-18 23:41:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,069 ms / 6,000 ms
コード長 1,837 bytes
コンパイル時間 1,893 ms
コンパイル使用メモリ 104,480 KB
実行使用メモリ 361,776 KB
最終ジャッジ日時 2023-09-06 02:15:26
合計ジャッジ時間 9,972 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,069 ms
361,716 KB
testcase_01 AC 1,067 ms
361,740 KB
testcase_02 AC 1,065 ms
361,740 KB
testcase_03 AC 1,066 ms
361,776 KB
testcase_04 AC 30 ms
16,312 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1,064 ms
361,748 KB
testcase_07 AC 3 ms
4,404 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 5 ms
6,420 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 7 ms
7,280 KB
testcase_12 AC 8 ms
7,992 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 783 ms
276,988 KB
権限があれば一括ダウンロードができます

ソースコード

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(1, vector<vector<double> >(1, vector<double>(len, 0.0)));
    dp[0][0][0] = 1.0;
    for(int i=0; i<n-1; ++i){
        dp.push_back(vector<vector<double> >(i+2, vector<double>(len, 0.0)));
        for(int a=0; a<=i; ++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