結果

問題 No.155 生放送とBGM
ユーザー 👑 kmjpkmjp
提出日時 2015-02-18 00:13:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4,735 ms / 6,000 ms
コード長 1,248 bytes
コンパイル時間 1,122 ms
コンパイル使用メモリ 146,020 KB
実行使用メモリ 11,272 KB
最終ジャッジ日時 2023-09-06 01:51:00
合計ジャッジ時間 23,803 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,901 ms
11,160 KB
testcase_01 AC 3,735 ms
11,232 KB
testcase_02 AC 4,735 ms
11,048 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 83 ms
11,124 KB
testcase_05 AC 6 ms
11,236 KB
testcase_06 AC 3,140 ms
11,272 KB
testcase_07 AC 8 ms
11,080 KB
testcase_08 AC 6 ms
11,240 KB
testcase_09 AC 10 ms
11,052 KB
testcase_10 AC 7 ms
11,084 KB
testcase_11 AC 11 ms
11,176 KB
testcase_12 AC 12 ms
11,084 KB
testcase_13 AC 8 ms
11,156 KB
testcase_14 AC 2,355 ms
11,228 KB
権限があれば一括ダウンロードができます

ソースコード

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[18200][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;
	FOR(j,N) {
		ZERO(dp);
		dp[0][0]=1;
		FOR(i,N) if(i!=j) {
			for(x=i;x>=0;x--) {
				FOR(y,L) if(dp[y][x]) dp[min(L,y+S[i])][x+1] += dp[y][x];
			}
		}
		FOR(y,L) {
			for(x=0;x<=N;x++) if(dp[y][x]) {
				ret += dp[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