結果

問題 No.155 生放送とBGM
ユーザー 沙耶花沙耶花
提出日時 2021-11-02 21:13:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,471 bytes
コンパイル時間 3,943 ms
コンパイル使用メモリ 257,196 KB
実行使用メモリ 712,776 KB
最終ジャッジ日時 2024-04-20 07:56:33
合計ジャッジ時間 12,394 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 AC 53 ms
115,404 KB
testcase_05 AC 3 ms
10,060 KB
testcase_06 MLE -
testcase_07 AC 16 ms
43,596 KB
testcase_08 AC 6 ms
20,168 KB
testcase_09 AC 24 ms
63,948 KB
testcase_10 AC 8 ms
25,800 KB
testcase_11 AC 30 ms
75,468 KB
testcase_12 AC 36 ms
88,016 KB
testcase_13 AC 11 ms
38,092 KB
testcase_14 MLE -
権限があれば一括ダウンロードができます

ソースコード

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;
long long dp[51][18002][51];
long long rdp[51][18002][51];
void get(vector<int> t){
	dp[0][0][0] = 1LL;
	
	rep(i,N){
		rep(j,L){
			rep(k,N+1){
				if(dp[i][j][k]==0)continue;
				dp[i+1][j][k] += dp[i][j][k];
				if(j+t[i]<L){
					dp[i+1][j+t[i]][k+1] += dp[i][j][k];
				}
			}
		}
	}

}

void rget(vector<int> t){
	rdp[0][0][0] = 1LL;
	
	rep(i,N){
		rep(j,L){
			rep(k,N+1){
				if(rdp[i][j][k]==0)continue;
				rdp[i+1][j][k] += rdp[i][j][k];
				if(j+t[i]<L){
					rdp[i+1][j+t[i]][k+1] += rdp[i][j][k];
				}
			}
		}
	}

}

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;
	
	get(t);
	reverse(t.begin(),t.end());
	rget(t);
	
	rep(i,N+1){
		rep(j,L-1){
			rep(k,N+1){
				rdp[i][j+1][k] += rdp[i][j][k];
			}
		}
	}
	
	rep(i,N){
		
		rep(j,L){
			rep(k,N+1){
				if(dp[i][j][k]==0)continue;
				rep(kk,N+1){
					double temp = dp[i][j][k] * rdp[N-1-i][L-1-j][kk];
					temp *= f[k+kk];
					temp *= f[(N-1)-k-kk];
					ans += temp;
				}
			}
		}
		
	}
	
	rep(i,N)ans /= i+1;
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	
	return 0;
	
}
0