結果
問題 | No.155 生放送とBGM |
ユーザー | tsutaj |
提出日時 | 2018-02-07 20:00:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 666 ms / 6,000 ms |
コード長 | 1,664 bytes |
コンパイル時間 | 547 ms |
コンパイル使用メモリ | 45,920 KB |
実行使用メモリ | 379,232 KB |
最終ジャッジ日時 | 2023-10-18 00:11:17 |
合計ジャッジ時間 | 4,969 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 560 ms
379,232 KB |
testcase_01 | AC | 497 ms
379,232 KB |
testcase_02 | AC | 300 ms
379,232 KB |
testcase_03 | AC | 2 ms
4,348 KB |
testcase_04 | AC | 57 ms
105,112 KB |
testcase_05 | AC | 4 ms
13,540 KB |
testcase_06 | AC | 666 ms
379,232 KB |
testcase_07 | AC | 11 ms
30,616 KB |
testcase_08 | AC | 7 ms
22,272 KB |
testcase_09 | AC | 14 ms
36,868 KB |
testcase_10 | AC | 9 ms
26,392 KB |
testcase_11 | AC | 14 ms
36,968 KB |
testcase_12 | AC | 16 ms
38,984 KB |
testcase_13 | AC | 12 ms
32,608 KB |
testcase_14 | AC | 390 ms
315,792 KB |
ソースコード
#include <cstdio> #include <algorithm> #include <cstring> using namespace std; int N, L, S[60]; long long int dp[2][60][18010]; long long int dp2[60][60][18010]; int main() { scanf("%d%d", &N, &L); L *= 60; int sum = 0; for(int i=0; i<N; i++) { int m, s; scanf("%d:%d", &m, &s); S[i] = 60*m + s; sum += S[i]; } if(sum <= L) { printf("%.12f\n", (double)N); return 0; } dp[0][0][0] = 1; for(int i=0; i<N; i++) { int cur = i%2, nxt = cur^1; for(int j=0; j<=i; j++) { for(int k=0; k<=L; k++) { dp[nxt][j][k] += dp[cur][j][k]; if(k - S[i] >= 0) dp[nxt][j+1][k] += dp[cur][j][k - S[i]]; } } memset(dp[cur], 0, sizeof(dp[cur])); } for(int i=0; i<N; i++) { dp2[i][0][0] = 1; int cur = N%2; for(int j=1; j<N; j++) { for(int k=0; k<=L; k++) { dp2[i][j][k] = dp[cur][j][k]; if(k-S[i] >= 0) dp2[i][j][k] -= dp2[i][j-1][k-S[i]]; } } } double ans = 0.0; for(int i=0; i<N; i++) { for(int l=max(0, L-S[i]); l<L; l++) { for(int j=0; j<N; j++) { long long int pat = dp2[i][j][l]; int X = j, Y = N-j-1; // combination double b = 1; for(int k=1; k<=min(X,Y); k++) { b *= (N - k); b /= k; } b *= N; b = ((X+1) * pat) / b; ans += b; } } } printf("%.12f\n", ans); return 0; }