結果

問題 No.155 生放送とBGM
ユーザー 👑 kmjpkmjp
提出日時 2015-02-18 00:46:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,393 bytes
コンパイル時間 1,212 ms
コンパイル使用メモリ 146,460 KB
実行使用メモリ 21,928 KB
最終ジャッジ日時 2023-09-06 01:53:26
合計ジャッジ時間 4,986 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 57 ms
17,636 KB
testcase_05 AC 5 ms
15,316 KB
testcase_06 AC 556 ms
21,768 KB
testcase_07 AC 9 ms
19,652 KB
testcase_08 AC 6 ms
17,768 KB
testcase_09 AC 11 ms
19,840 KB
testcase_10 AC 7 ms
17,704 KB
testcase_11 AC 13 ms
21,808 KB
testcase_12 AC 15 ms
19,760 KB
testcase_13 AC 8 ms
17,704 KB
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,L;
int S[100];
int sum;
double fact[100];

ll dp[22000][53];
double dp2[22000][53];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	fact[0]=fact[1]=1;
	for(i=2;i<=80;i++) fact[i]=fact[i-1]*i;
	
	scanf("%d%d",&N,&L);
	L*=60;
	FOR(i,N) {
		scanf("%d:%d",&x,&y);
		S[i]=x*60+y;
		sum+=S[i];
	}
	if(L>=sum) return _P("%d\n",N);
	
	double ret=0;
	dp[0][0]=1;
	FOR(i,N) {
		for(x=i;x>=0;x--) {
			FOR(y,22000) dp[min(22000,y+S[i])][x+1] += dp[y][x];
		}
	}
	ll hoge=0;
	FOR(x,N+1) FOR(y,22001) hoge += dp[y][x];
	
	FOR(i,N) {
		for(x=0;x<=N;x++) {
			for(y=0;y<=L+S[i]-1;y++) {
				dp2[y][x]=dp[y][x];
				if(y>=S[i] && x>0) dp2[y][x]=dp[y][x]-dp2[y-S[i]][x-1];
				if(x<N && y<L) ret += dp2[y][x] * fact[x] * fact[N-(x+1)];
			}
		}
	}
	
	ret /= fact[N];
	_P("%.12lf\n",ret);
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0