結果

問題 No.155 生放送とBGM
ユーザー yosupotyosupot
提出日時 2015-02-18 00:01:37
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2,049 ms / 6,000 ms
コード長 1,207 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 69,320 KB
実行使用メモリ 12,352 KB
最終ジャッジ日時 2024-06-23 20:39:30
合計ジャッジ時間 15,470 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘double solve()’:
main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |         scanf("%d:%d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

//#define NDEBUG
 
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <cassert>
#include <numeric>

using namespace std;
typedef long long ll;


double fact(int n) {
    if (n <= 1) return 1;
    return fact(n-1)*n;
}
int d[55];
double dp[55][20000];
double solve() {
    int n, l;
    cin >> n >> l;
    for (int i = 0; i < n; i++) {
        int x, y;
        scanf("%d:%d", &x, &y);
        d[i] = x*60+y;
    }
    double res = 0;
    for (int i = 0; i < n; i++) {
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            for (int u = 54; u >= 1; u--) {
                for (int k = 19000; k >= d[j]; k--) {
                    dp[u][k] += dp[u-1][k-d[j]];
                }
            }
        }
        for (int u = 0; u < 55; u++) {
            double p = 0;
            for (int k = 0; k < 60*l; k++) {
                p += dp[u][k];
            }
            p *= fact(u)*fact(n-(u+1));
            res += p;
        }
    }
    return res/fact(n);
}


int main() {
    printf("%.20f\n", solve());
    return 0;
}
0