結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 112 ms
21,808 KB
testcase_05 AC 15 ms
21,368 KB
testcase_06 AC 980 ms
21,492 KB
testcase_07 AC 22 ms
21,888 KB
testcase_08 AC 17 ms
21,804 KB
testcase_09 AC 28 ms
21,768 KB
testcase_10 AC 20 ms
21,816 KB
testcase_11 AC 29 ms
21,736 KB
testcase_12 AC 31 ms
21,972 KB
testcase_13 AC 24 ms
21,804 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];

double 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];
		}
	}
	FOR(i,N) {
		memmove(dp2,dp,sizeof(dp2));
		for(x=1;x<=N;x++) {
			for(y=0;y<=L+S[i]-1;y++) {
				if(y>=S[i]) dp2[y][x]=dp[y][x]-dp2[y-S[i]][x-1];
			}
		}
		FOR(x,N+1) FOR(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