結果
| 問題 |
No.155 生放送とBGM
|
| コンテスト | |
| ユーザー |
Div9851
|
| 提出日時 | 2017-10-11 15:50:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 984 bytes |
| コンパイル時間 | 2,035 ms |
| コンパイル使用メモリ | 160,044 KB |
| 実行使用メモリ | 18,256 KB |
| 最終ジャッジ日時 | 2024-11-17 09:41:41 |
| 合計ジャッジ時間 | 3,182 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d:%d", &mm, &ss);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL INF = (1LL << 31) - 1;
const LL MOD = 1000000007LL;
using namespace std;
double dp[51][18001];
double dp2[51][18001];
double fact[51];
int main() {
int t[50];
int N, L;
cin >> N >> L;
L *= 60;
fact[0] = 1;
for (int i = 1; i <= N; i++) fact[i] = fact[i - 1] * i;
int sum = 0;
rep(i, N) {
int mm, ss;
scanf("%d:%d", &mm, &ss);
t[i] = mm * 60 + ss;
sum += t[i];
}
if (sum <= L) {
cout << N << endl;
return 0;
}
dp[0][0] = 1;
rep(i, N) {
for(int j=N-1;j>=0;j--) {
for (int k = 0; k <= L; k++) {
if (k - t[i] >= 0) dp[j + 1][k] += dp[j][k - t[i]];
}
}
}
double ret = 0;
rep(i, N) {
rep(j, N) {
for (int k = 0; k <= L-1; k++) {
dp2[j][k] = dp[j][k];
if (j > 0 && k >= t[i]) dp2[j][k] -= dp2[j - 1][k - t[i]];
ret += dp2[j][k] * fact[j] * fact[N - 1 - j];
}
}
}
cout << ret / fact[N] << endl;
}
Div9851