結果

問題 No.155 生放送とBGM
ユーザー Yang33Yang33
提出日時 2018-05-07 23:24:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,783 bytes
コンパイル時間 1,763 ms
コンパイル使用メモリ 172,916 KB
実行使用メモリ 4,420 KB
最終ジャッジ日時 2023-09-10 10:59:45
合計ジャッジ時間 3,661 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,380 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 };


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

	VVI dp(N + 1, VI(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(62);
	fact[0] = fact[1] = 1;
	FOR(i, 1, 50) {
		fact[i + 1] = fact[i] * (i + 1);
	}

	double ans = 0;

	FOR(i, 0, N) {
		VVI 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(15) << ans << "\n";

	return 0;
}
0