結果

問題 No.155 生放送とBGM
ユーザー koprickykopricky
提出日時 2017-10-17 07:59:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 176 ms / 6,000 ms
コード長 2,065 bytes
コンパイル時間 1,364 ms
コンパイル使用メモリ 147,648 KB
実行使用メモリ 100,668 KB
最終ジャッジ日時 2023-08-11 07:34:27
合計ジャッジ時間 3,089 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 176 ms
100,668 KB
testcase_01 AC 174 ms
100,596 KB
testcase_02 AC 168 ms
100,604 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 22 ms
58,168 KB
testcase_05 AC 2 ms
5,660 KB
testcase_06 AC 176 ms
99,248 KB
testcase_07 AC 4 ms
12,176 KB
testcase_08 AC 2 ms
7,780 KB
testcase_09 AC 7 ms
16,760 KB
testcase_10 AC 3 ms
10,092 KB
testcase_11 AC 7 ms
16,764 KB
testcase_12 AC 7 ms
17,012 KB
testcase_13 AC 4 ms
14,184 KB
testcase_14 AC 135 ms
92,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 220002;
double dp[52][MAX_N];
double dpp[52][MAX_N];
double fac[52];

int main()
{
    int n,L;
    cin >> n >> L;
    L *= 60;
    vi vec(n);
    rep(i,n){
        int a,b;
        scanf("%d:%d",&a,&b);
        vec[i] = 60*a+b;
    }
    int sm = accumulate(all(vec),0);
    int mx = *max_element(all(vec));
    if(sm <= L){
        cout << n << endl;
        return 0;
    }
    dp[0][0] = 1;
    rep(i,n){
        rrep(j,n){
            rep(k,L){
                dp[j+1][k+vec[i]] += dp[j][k];
            }
        }
    }
    fac[0] = 1;
    rep(i,n){
        fac[i+1] = fac[i]*(i+1);
    }
    double ans = 0;
    rrep(i,n){
        rep(j,n+1){
            rep(k,L+mx){
                dpp[j][k] = dp[j][k];
            }
        }
        rep(j,n){
            rep(k,L){
                dpp[j+1][k+vec[i]] -= dpp[j][k];
            }
        }
        rep(j,n){
            srep(k,max(0,L-vec[i]),L){
                ans += (j+1)*fac[j]*dpp[j][k]*fac[n-j-1];
            }
        }
    }
    printf("%.12lf\n",ans/fac[n]);
    return 0;
}
0