結果

問題 No.155 生放送とBGM
ユーザー 沙耶花沙耶花
提出日時 2021-11-02 21:41:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 462 ms / 6,000 ms
コード長 1,220 bytes
コンパイル時間 4,690 ms
コンパイル使用メモリ 258,784 KB
実行使用メモリ 19,092 KB
最終ジャッジ日時 2024-04-20 08:22:31
合計ジャッジ時間 8,285 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 390 ms
18,964 KB
testcase_01 AC 385 ms
19,088 KB
testcase_02 AC 462 ms
18,956 KB
testcase_03 AC 453 ms
19,092 KB
testcase_04 AC 24 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 375 ms
19,092 KB
testcase_07 AC 7 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 14 ms
5,724 KB
testcase_12 AC 16 ms
5,796 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 315 ms
16,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
int N,L;

int main(){	
	
	
	cin>>N>>L;
	
	L *= 60;
	
	vector<int> t(N);
	long long sum = 0;
	rep(i,N){
		int m,s;
		scanf("%d:%d",&m,&s);
		t[i] = m*60+s;
		sum += t[i];
	}
	
	vector<double> f(N+5,1.0);
	for(int i=1;i<f.size();i++)f[i] = f[i-1] * i;
	
	double ans = 0.0;
	
	
	
	vector dp(L,vector<long long>(N+1,0));
	dp[0][0] = 1;
	
	rep(i,N){
		vector ndp(L,vector<long long>(N+1,0));
		rep(j,L){
			rep(k,N+1){
				if(dp[j][k]==0)continue;
				ndp[j][k] += dp[j][k];
				if(j+t[i]<L)ndp[j+t[i]][k+1] += dp[j][k];
			}
		}
		swap(dp,ndp);
	}
	
	
	rep(i,N){
		vector ndp(L,vector<long long>(N+1,0));
		rep(j,L){
			rep(k,N+1){
				ndp[j][k] = dp[j][k];
				if(j-t[i]>=0&&k>=1){
					ndp[j][k] -= ndp[j-t[i]][k-1];
				}
			}
		}
		swap(dp,ndp);
		rep(j,L){
			rep(k,N+1){
				if(dp[j][k]==0)continue;
				
				double temp = dp[j][k];
				temp *= f[k];
				temp *= f[(N-1)-k];
				ans += temp;
				
			}
		}
		swap(dp,ndp);
		
	}
	
	rep(i,N)ans /= i+1;
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	
	return 0;
	
}
0