結果
問題 | No.155 生放送とBGM |
ユーザー |
![]() |
提出日時 | 2021-01-12 20:24:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 183 ms / 6,000 ms |
コード長 | 1,356 bytes |
コンパイル時間 | 1,974 ms |
コンパイル使用メモリ | 197,704 KB |
最終ジャッジ日時 | 2025-01-17 16:47:36 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d%d", &n, &l); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%d:%d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>using namespace std;const int M = 1000000007;using P = pair<int, int>;int main() {// cin.tie(0);// ios::sync_with_stdio(0);int n, l;scanf("%d%d", &n, &l);l *= 60;vector<int> a(n);for (int i = 0; i < n; ++i) {int x, y;scanf("%d:%d", &x, &y);a[i] = min(l, x * 60 + y);}double facts[n + 1];facts[0] = 1;for (int i = 1; i <= n; ++i) {facts[i] = facts[i - 1] * i;}double dp[n][l] = {};double dp2[n][l];dp[0][0] = 1;for (int i = 0; i < n; ++i) {for (int j = n - 1; j > 0; --j) {for (int k = l - 1; k >= a[i]; --k) {dp[j][k] += dp[j - 1][k - a[i]];}}}double ans = 0;for (int i = 0; i < n; ++i) {for (int j = 0; j < n; ++j) {for (int k = 0; k < l; ++k) {dp2[j][k] = dp[j][k];}}for (int j = 1; j < n; ++j) {for (int k = a[i]; k < l; ++k) {dp2[j][k] -= dp2[j - 1][k - a[i]];}}for (int j = 0; j < n; ++j) {for (int k = 0; k < l; ++k) {ans += dp2[j][k] * facts[j] * facts[n - j - 1];}}}cout << setprecision(16) << ans / facts[n] << '\n';return 0;}