結果
問題 | No.155 生放送とBGM |
ユーザー |
![]() |
提出日時 | 2015-02-18 00:13:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4,368 ms / 6,000 ms |
コード長 | 1,248 bytes |
コンパイル時間 | 1,298 ms |
コンパイル使用メモリ | 159,996 KB |
実行使用メモリ | 11,324 KB |
最終ジャッジ日時 | 2024-06-23 20:53:25 |
合計ジャッジ時間 | 22,338 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’: main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d%d",&N,&L); | ~~~~~^~~~~~~~~~~~~~ main.cpp:30:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 30 | scanf("%d:%d",&x,&y); | ~~~~~^~~~~~~~~~~~~~~
ソースコード
#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;}