結果

問題 No.155 生放送とBGM
ユーザー yuustiyuusti
提出日時 2015-02-18 00:43:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 186 ms / 6,000 ms
コード長 1,746 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 77,652 KB
実行使用メモリ 23,100 KB
最終ジャッジ日時 2023-09-06 01:53:19
合計ジャッジ時間 2,678 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 186 ms
22,936 KB
testcase_01 AC 182 ms
23,100 KB
testcase_02 AC 179 ms
23,036 KB
testcase_03 AC 180 ms
23,012 KB
testcase_04 AC 26 ms
19,912 KB
testcase_05 AC 5 ms
15,928 KB
testcase_06 AC 184 ms
22,884 KB
testcase_07 AC 7 ms
15,872 KB
testcase_08 AC 5 ms
15,932 KB
testcase_09 AC 8 ms
15,840 KB
testcase_10 AC 5 ms
15,800 KB
testcase_11 AC 9 ms
15,820 KB
testcase_12 AC 9 ms
15,916 KB
testcase_13 AC 7 ms
15,768 KB
testcase_14 AC 142 ms
22,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

ll dp[55][22000];
ll dp2[55][22000];
ll ans[55][22000];

ld fact[55];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	fact[0] = 1;
	for (int i = 1; i < 55; ++i) fact[i] = fact[i - 1] * i;

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

	int MX = L + 3600;
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i){
		for (int j = i; j >= 0; --j){
			rep(k, MX){
				dp[j + 1][min(k + s[i], MX)] += dp[j][k];
			}
		}
	}

	ld ans = 0;
	for (int i = 0; i < n; ++i){
		MEMSET(dp2, 0);
		dp2[0][0] = 1;
		for (int j = 1; j <= n; ++j){
			for (int k = 0; k < L + s[i]; ++k){
				dp2[j][k] = dp[j][k];
				if (k - s[i] >= 0) dp2[j][k] -= dp2[j - 1][k - s[i]];
			}
		}

		rep(i, n){
			ld tmp = 0;
			rep(j, L){
				tmp += dp2[i][j];
			}
			ans += tmp*fact[i]*fact[n - 1 - i];
		}
	}

	cout << ans / fact[n] << endl;
}
0