結果
問題 | No.155 生放送とBGM |
ユーザー |
![]() |
提出日時 | 2021-11-02 21:10:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,287 bytes |
コンパイル時間 | 4,689 ms |
コンパイル使用メモリ | 256,648 KB |
最終ジャッジ日時 | 2025-01-25 10:30:49 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 MLE * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:41:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 41 | scanf("%d:%d",&m,&s); | ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using mint = modint;using namespace std;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf 1000000001int N,L;vector<vector<vector<long long>>> get(vector<int> t){vector dp(N+1,vector(L,vector<long long>(N+1,0)));dp[0][0][0] = 1LL;rep(i,N){rep(j,L){rep(k,N+1){if(dp[i][j][k]==0)continue;dp[i+1][j][k] += dp[i][j][k];if(j+t[i]<L){dp[i+1][j+t[i]][k+1] += dp[i][j][k];}}}}return dp;}int main(){cin>>N>>L;L *= 60;vector<int> t(N);long long sum = 0;rep(i,N){int m,s;scanf("%d:%d",&m,&s);t[i] = m*60+s;sum += t[i];}vector<double> f(N+5,1.0);for(int i=1;i<f.size();i++)f[i] = f[i-1] * i;double ans = 0.0;auto dp = get(t);reverse(t.begin(),t.end());auto rdp = get(t);rep(i,N+1){rep(j,L-1){rep(k,N+1){rdp[i][j+1][k] += rdp[i][j][k];}}}rep(i,N){rep(j,L){rep(k,N+1){if(dp[i][j][k]==0)continue;rep(kk,N+1){double temp = dp[i][j][k] * rdp[N-1-i][L-1-j][kk];temp *= f[k+kk];temp *= f[(N-1)-k-kk];ans += temp;}}}}rep(i,N)ans /= i+1;cout<<fixed<<setprecision(10)<<ans<<endl;return 0;}