結果

問題 No.155 生放送とBGM
ユーザー yuustiyuusti
提出日時 2015-02-18 00:27:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,136 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 78,292 KB
実行使用メモリ 14,020 KB
最終ジャッジ日時 2023-09-06 01:52:22
合計ジャッジ時間 1,659 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 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;
	}

	if (accumulate(ALL(s), 0) - *min_element(ALL(s)) < L){
		cout << n << endl;
	}
	else{
		//sort(ALL(s));
		//ld x = 0;
		//ll cnt = 0;
		//ll ccnt[6] = {};
		//do{
		//	ll sum = 0;
		//	for (int i = 0; i <= s.size(); ++i){
		//		if (sum >= L){
		//			x += i;
		//			ccnt[i]++;
		//			break;
		//		}
		//		sum += s[i];
		//	}
		//	++cnt;
		//} while (next_permutation(ALL(s)));
		//cout << x / cnt << endl;
		//rep(i, 6){
		//	cout << "answer : " << ccnt[i] << endl;
		//}

		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){
			ld cnt = 0;
			for (int j = 1; j <= n; ++j){
				ld tmp = 0;
				for (int k = max(s[i], L); k < L + s[i]; ++k){
					if(dp[j][k]) tmp += dp[j - 1][k - s[i]];
				}
				cnt += tmp*j*fact[j - 1] * fact[n - j];
			}
			ans += cnt;
		}

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