結果

問題 No.155 生放送とBGM
ユーザー Div9851Div9851
提出日時 2017-10-11 15:50:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 984 bytes
コンパイル時間 1,428 ms
コンパイル使用メモリ 159,008 KB
実行使用メモリ 18,128 KB
最終ジャッジ日時 2024-04-28 16:07:52
合計ジャッジ時間 3,091 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 151 ms
16,512 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0