結果

問題 No.155 生放送とBGM
ユーザー pazzle1230pazzle1230
提出日時 2019-02-07 01:47:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 574 ms / 6,000 ms
コード長 1,644 bytes
コンパイル時間 1,881 ms
コンパイル使用メモリ 174,852 KB
実行使用メモリ 20,852 KB
最終ジャッジ日時 2023-09-05 11:24:13
合計ジャッジ時間 6,456 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 518 ms
20,852 KB
testcase_01 AC 515 ms
20,768 KB
testcase_02 AC 509 ms
20,704 KB
testcase_03 AC 492 ms
20,704 KB
testcase_04 AC 51 ms
5,904 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 496 ms
20,724 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 8 ms
4,772 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 10 ms
5,016 KB
testcase_12 AC 9 ms
5,276 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 574 ms
17,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int64 N, L;
vector<int64> S;
vector<double> fact;

int64 get(const vector<vector<int64>> &v, int64 i, int64 j){
	if (i < 0 || j < 0) return 0;
	return v[i][j];
}

void init(){
	fact.resize(100, 1);
	FOR(i, 1, 100){
		fact[i] = fact[i-1] * i;
	}
}

int main(void){
	init();
	cin >> N >> L;
	L *= 60;
	S.resize(N);
	REP(i, N){
		int64 m, s;
		scanf("%d:%d", &m, &s);
		S[i] = m*60+s;
	}
	vector<vector<int64>> dp(N+1, vector<int64>(L+60*60+1, 0));
	dp[0][0] = 1;
	REP(i, N){
		vector<vector<int64>> dp2(N+1, vector<int64>(L+60*60+1, 0));
		REP(j, N+1){
			REP(k, L+60*60+1){
				dp2[j][k] = get(dp, j-1, k-S[i]) + get(dp, j, k);
			}
		}
		swap(dp, dp2);
	}
	double res = 0;
	REP(i, N){
		vector<vector<int64>> dp2(N+1, vector<int64>(L+60*60+1, 0));
		REP(j, N+1){
			REP(k, L+60*60+1){
				dp2[j][k] = dp[j][k] - get(dp2, j-1, k-S[i]);
				if (k < L && N-j-1 >= 0)
					res += dp2[j][k] * fact[j] * fact[N-j-1] / fact[N];
			}
		}
	}
	cout << fixed << setprecision(10) << res << endl;
}
0