結果

問題 No.155 生放送とBGM
ユーザー Div9851Div9851
提出日時 2017-10-11 15:52:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 148 ms / 6,000 ms
コード長 988 bytes
コンパイル時間 1,327 ms
コンパイル使用メモリ 159,656 KB
実行使用メモリ 18,124 KB
最終ジャッジ日時 2024-04-28 16:08:29
合計ジャッジ時間 2,896 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
18,004 KB
testcase_01 AC 145 ms
18,124 KB
testcase_02 AC 148 ms
18,000 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 8 ms
10,236 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 144 ms
17,040 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,948 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 4 ms
6,940 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 112 ms
16,860 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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];
			}
		}
	}
	printf("%.15lf\n", ret / fact[N]);
}
0