結果
問題 | No.155 生放送とBGM |
ユーザー | 👑 kmjp |
提出日時 | 2015-02-18 00:51:36 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 833 ms / 6,000 ms |
コード長 | 1,328 bytes |
コンパイル時間 | 1,239 ms |
コンパイル使用メモリ | 146,412 KB |
実行使用メモリ | 21,980 KB |
最終ジャッジ日時 | 2023-09-06 01:53:33 |
合計ジャッジ時間 | 6,634 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 760 ms
21,724 KB |
testcase_01 | AC | 785 ms
21,980 KB |
testcase_02 | AC | 699 ms
21,772 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 67 ms
17,752 KB |
testcase_05 | AC | 6 ms
15,040 KB |
testcase_06 | AC | 833 ms
21,700 KB |
testcase_07 | AC | 10 ms
19,776 KB |
testcase_08 | AC | 7 ms
17,684 KB |
testcase_09 | AC | 13 ms
19,656 KB |
testcase_10 | AC | 8 ms
17,696 KB |
testcase_11 | AC | 15 ms
21,784 KB |
testcase_12 | AC | 16 ms
19,768 KB |
testcase_13 | AC | 9 ms
17,676 KB |
testcase_14 | AC | 598 ms
21,860 KB |
ソースコード
#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[22005][53]; ll dp2[22005][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); dp[0][0]=1; FOR(i,N) { for(x=i;x>=0;x--) { FOR(y,22001) dp[min(22000,y+S[i])][x+1] += dp[y][x]; } } double ret=0; 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]-=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; }