結果

問題 No.155 生放送とBGM
ユーザー Yang33Yang33
提出日時 2018-05-07 23:08:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,030 bytes
コンパイル時間 2,488 ms
コンパイル使用メモリ 174,672 KB
実行使用メモリ 5,264 KB
最終ジャッジ日時 2023-09-10 10:59:28
合計ジャッジ時間 3,540 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/05/05  Problem: yukicoder 155  / Link: http://yukicoder.me/problems/no/155  ----- */
/* ------問題------

ユキさんは生放送で配信する際に,BGMとしてクララーリスというグループの曲を流しています.
ユキさんのミュージックプレイヤーには,クララーリスの曲が N 曲登録されており,その k 曲目の長さは Sk です.
また,ユキさんが生放送で配信する時間は L 分です.
ミュージックプレイヤーはランダム再生機能があり,まず,登録されている曲をランダムに並べ替えて,順番に再生されます.
また,全ての曲が再生された後は,再びランダムに並び替えて,順番に再生されます.
ユキさんの放送中に 1 秒でも流れる曲は何曲になるかという期待値を求めるプログラムを書いて下さい.
ランダムに並べ替える際は,N! パターンの並び替え方が等確率で起こるものとし,毎回独立に並び替えるとして下さい.
また,ユキさんは生放送が始まると同時に再生し始めます.

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N, L; cin >> N >> L;
	L *= 60;
	VI a(N);
	FOR(i, 0, N) {
		int m, s;
		scanf("%d:%d", &m, &s);
		a[i] = 60 * m + s;
	}
	int sum = accumulate(ALL(a), 0);

	if (sum <= L) {
		cout << N << endl; return 0;
	}

	VVL dp(N + 1, VL(L +4000, 0));
	dp[0][0] = 1;
	FOR(i, 0, N) {
		FORR(j, N - 1, 0 - 1) {
			FOR(k, a[i], L + 1) {
				dp[j + 1][k] += dp[j][k - a[i]];
			}
		}
	}
	vector<double>fact(51);
	fact[0] = fact[1] = 1;
	FOR(i, 1, 50) {
		fact[i + 1] = fact[i] * (i + 1);
	}

	double ans = 0;

	FOR(i, 0, N) {
		VVL diffdp = dp;
		FOR(j, 0, N) {
			FOR(k, 0, L) {
				diffdp[j + 1][k + a[i]] -= diffdp[j][k];
			}
		}
		FOR(j, 0, N) {
			FOR(k, max(0, L - a[i]), L) {
				ans += 1.*(j + 1)*diffdp[j][k] * fact[j] * fact[N - j - 1];
			}
		}
	}

	ans /= fact[N];
	cout << fixed << setprecision(10) << ans << "\n";

	return 0;
}
0