結果

問題 No.155 生放送とBGM
ユーザー drken1215drken1215
提出日時 2020-10-07 04:10:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 484 ms / 6,000 ms
コード長 2,508 bytes
コンパイル時間 2,214 ms
コンパイル使用メモリ 208,252 KB
実行使用メモリ 24,888 KB
最終ジャッジ日時 2023-09-27 09:07:07
合計ジャッジ時間 6,308 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 484 ms
24,884 KB
testcase_01 AC 455 ms
24,688 KB
testcase_02 AC 445 ms
24,692 KB
testcase_03 AC 469 ms
24,884 KB
testcase_04 AC 18 ms
4,720 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 458 ms
24,888 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 7 ms
4,564 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 8 ms
5,188 KB
testcase_12 AC 8 ms
5,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 329 ms
20,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

vector<vector<long long>> add(vector<vector<long long>> dp, int v) {
    auto res = dp;
    for (int j = 1; j < res.size(); ++j) {
        for (int k = v; k < res[0].size(); ++k) {
            res[j][k] += dp[j-1][k-v];
        }
    }
    return res;
}

vector<vector<long long>> sub(vector<vector<long long>> dp, int v) {
    auto res = dp;
    for (int j = 1; j < res.size(); ++j) {
        for (int k = v; k < res[0].size(); ++k) {
            res[j][k] -= res[j-1][k-v];
        }
    }
    return res;
}

double com(int n, int r) {
    double res = 1;
    for (int i = 0; i < r; ++i) {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}

int main() {
    int N, L;
    cin >> N >> L;
    L *= 60;
    vector<int> S(N);
    for (int i = 0; i < N; ++i) {
        string str;
        cin >> str;
        int m = (str[0]-'0')*10 + (str[1]-'0');
        int s = (str[3]-'0')*10 + (str[4]-'0');
        S[i] = m*60+s;
    }

    double res = 0;
    vector<vector<long long>> dp(N+1, vector<long long>(L+1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) dp = add(dp, S[i]);
    for (int i = 0; i < N; ++i) {
        double tmp = 0;
        auto sdp = sub(dp, S[i]);
        for (int k = 0; k < N; ++k) {
            double num = 0;
            for (int j = 0; j <= L-1; ++j) num += sdp[k][j];
            tmp += num / com(N-1, k);
        }
        res += tmp / N;
    }
    cout << fixed << setprecision(10) << res << endl;
}
0