結果

問題 No.155 生放送とBGM
ユーザー nxterunxteru
提出日時 2018-07-01 11:23:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,089 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 68,568 KB
実行使用メモリ 183,900 KB
最終ジャッジ日時 2023-09-13 16:32:46
合計ジャッジ時間 3,157 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
int n,a[55],l,z;
double s[55],dp[55][55][22000],f[60],ans,d[55][22000];
int main(void){
    cin>>n>>l;
    l*=60;
    for(int i=0;i<n;i++){
        int x,y;
        char c;
        cin>>x>>c>>y;
        a[i]=x*60+y;
        z+=a[i];
    }
    if(z<=l){
        cout<<n<<endl;
        return 0;
    }
    f[0]=1;
    for(int i=1;i<=n;i++)f[i]=f[i-1]*double(i);
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<22000;k++){
                if(dp[i][j][k]>0){
                    dp[i+1][j+1][k+a[i]]+=dp[i][j][k];
                    dp[i+1][j][k]+=dp[i][j][k];
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<l;k++){
                if(j>0&&k-a[i]>=0)d[j][k]=dp[n][j][k]-d[j-1][k-a[i]];
                else d[j][k]=dp[n][j][k];
                if(k+a[i]>=l){
                    ans+=d[j][k]*f[j]*f[n-j-1]*double(j+1);
                }
            }
        }
    }
    cout<<ans/f[n]<<endl;
}
0