結果

問題 No.155 生放送とBGM
ユーザー pekempeypekempey
提出日時 2015-11-07 22:49:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 129 ms / 6,000 ms
コード長 1,450 bytes
コンパイル時間 1,146 ms
コンパイル使用メモリ 146,960 KB
実行使用メモリ 20,044 KB
最終ジャッジ日時 2023-10-11 15:15:38
合計ジャッジ時間 2,851 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
19,892 KB
testcase_01 AC 129 ms
20,044 KB
testcase_02 AC 129 ms
19,904 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 23 ms
13,128 KB
testcase_05 AC 2 ms
5,640 KB
testcase_06 AC 120 ms
18,956 KB
testcase_07 AC 2 ms
5,884 KB
testcase_08 AC 3 ms
5,816 KB
testcase_09 AC 3 ms
6,184 KB
testcase_10 AC 2 ms
5,884 KB
testcase_11 AC 4 ms
6,244 KB
testcase_12 AC 4 ms
6,240 KB
testcase_13 AC 3 ms
5,756 KB
testcase_14 AC 103 ms
19,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define chmin(a, b) ((b) < a && (a = (b), true))
#define chmax(a, b) (a < (b) && (a = (b), true))
using namespace std;
typedef long long ll;

double fact[100];
double dp[55][20202], dp2[55][20202];

int main() {
	fact[0] = 1;
	rep (i, 1, 100) fact[i] = i * fact[i - 1];
	int N, L;
	cin >> N >> L;	
	vector<int> a(N);
	L *= 60;
	int sum = 0;
	rep (i, N) {
		string s;
		cin >> s;
		int minute = (s[0] - '0') * 10 + (s[1] - '0');
		int second = (s[3] - '0') * 10 + (s[4] - '0');
		a[i] = minute * 60 + second;
		sum += a[i];
	}
	if (sum < L) {
		cout << N << endl;
		return 0;
	}
	dp[0][0] = 1;
	rep (i, N) repr (j, 1, N) repr (k, a[i], 20202) {
		// dp[i + 1][j][k] = dp[i][j][k] + dp[i][j - 1][k - a[i]]
		dp[j][k] += dp[j - 1][k - a[i]];
	}
	double ans = 0;
	rep (i, N) rep (j, N + 1) rep (k, L) {
		// dp[n - 1][j][k] = dp[n][j][k] - dp[n - 1][j - 1][k - a[i]]
		dp2[j][k] = dp[j][k];
		if (j - 1 >= 0 && k - a[i] >= 0) dp2[j][k] -= dp2[j - 1][k - a[i]];
		ans += dp2[j][k] * fact[j] * fact[N - (j + 1)];
	}
	ans /= fact[N];
	printf("%.20f\n", ans);
	return 0;
}
0