結果

問題 No.2158 X日後に全完するhibit君
ユーザー t98slidert98slider
提出日時 2022-12-09 23:22:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 2,063 bytes
コンパイル時間 1,840 ms
コンパイル使用メモリ 169,856 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 23:04:18
合計ジャッジ時間 2,544 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, K;
    cin >> n >> K;
    vector<int> P(n), A(n), B(n);
    for(int i = 0; i < n; i++)cin >> P[i] >> A[i] >> B[i];
    if(accumulate(A.begin(), A.end(), 0) <= 60){
        cout << 1 << ' ' << 1 << ' ' << 1 << '\n';
        return 0;
    }
    if(accumulate(B.begin(), B.end(), 0) > 60){
        cout << -1 << '\n';
        return 0;
    }
    vector<int> idx;
    for(int i = 0; i < n; i++){
        for(int j = K + 1; j < P[i]; j++)idx.push_back(i);
    }
    int m = idx.size(), mx = K + 2;
    double ans = K + 2;
    vector<double> dp(1 << m);
    vector<int> dp2(1 << m);
    dp[0] = 1;
    dp2[0] = K + 2;
    for(int i = 0; i < (1 << m); i++){
        if(!dp2[i])continue;
        int S = 0, S2 = 0;
        mx = max(mx, dp2[i]);
        for(int j = 0; j < m; j++){
            if((i >> j & 1) || (S2 >> idx[j] & 1))continue;
            S2 |= 1 << idx[j];
            S |= 1 << j;
        }
        auto f = [&](int S){
            array<int, 6> cnt{};
            int tim = 0, S2 = 0;
            double res = 1;
            for(int j = 0; j < m; j++){
                if(~i >> j & 1)cnt[idx[j]]++;
                if(S >> j & 1)S2 |= 1 << idx[j];
            }
            for(int j = 0; j < n; j++){
                if(S2 >> j & 1){
                    tim += A[j];
                    res *= double(cnt[j]) / (P[j] - K);
                }else{
                    tim += B[j];
                    res *= double(P[j] - K - cnt[j]) / (P[j] - K);
                }
            }
            return make_pair(tim, res);
        };
        for(int T = S; T > 0; T = (T - 1) & S){
            auto pa = f(T);
            if(pa.first > 60){
                double v = dp[i] * pa.second;
                ans += v;
                dp[i | T] += v;
                dp2[i | T] = max(dp2[i | T], dp2[i] + 1);
            }
        }
    }
    cout << fixed << setprecision(15) << K + 2 << " " << mx << " " << ans << '\n';
}
0