結果

問題 No.155 生放送とBGM
ユーザー Yang33Yang33
提出日時 2018-05-07 23:42:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 422 ms / 6,000 ms
コード長 1,737 bytes
コンパイル時間 1,663 ms
コンパイル使用メモリ 175,336 KB
実行使用メモリ 20,836 KB
最終ジャッジ日時 2023-09-10 11:01:14
合計ジャッジ時間 4,880 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 409 ms
20,700 KB
testcase_01 AC 404 ms
20,748 KB
testcase_02 AC 398 ms
20,836 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 30 ms
6,072 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 422 ms
20,696 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 5 ms
4,676 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 7 ms
4,864 KB
testcase_12 AC 7 ms
5,284 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 319 ms
17,948 KB
権限があれば一括ダウンロードができます

ソースコード

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() {


	int N, L; cin >> N >> L;
	L *= 60;
	VI a(N);
	FOR(i, 0, N) {
		int m, s; char c;
		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(52);
	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 += (j+1)*diffdp[j][k]* fact[j] *fact[N - j - 1];
			}
		}
	}

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

	return 0;
}
0