結果

問題 No.2158 X日後に全完するhibit君
ユーザー 👑 rin204rin204
提出日時 2022-12-09 22:20:06
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 2,277 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 208,592 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 22:27:29
合計ジャッジ時間 2,919 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// #define endl '\n'
const ll MOD = 998244353;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    cout << fixed << setprecision(12);

    int n, k;
    cin >> n >> k;
    int stot = 0, ttot = 0;
    vector<int> P(n), S(n), T(n);
    for(int i = 0; i < n; i++){
        cin >> P[i] >> S[i] >> T[i];
        stot += S[i];
        ttot += T[i];
    }
    if(stot <= 60){
        cout << "1 1 1" << endl;
        return 0;
    }
    else if(ttot > 60){
        cout << -1 << endl;
        return 0;
    }

    auto f=[&](vector<int> A){
        int ret = 0;
        for(auto a:A) ret = ret * 6 + a;
        return ret;
    };

    auto g=[&](int x){
        vector<int> ret(n);
        for(int i = n - 1; i >= 0; i--){
            ret[i] = x % 6;
            x /= 6;
        }
        return ret;
    };

    int mi = 1 << 30;
    int ma = 0;
    long double ave = 0;
    map<int, long double> PP;
    vector<int> V(n, k);
    PP[f(V)] = 1.0;

    int day = k + 1;
    while(!PP.empty()){
        map<int, long double> NP;
        for(auto tmp:PP){
            auto A = g(tmp.first);
            long double p = tmp.second;

            for(auto bit = 0; bit < (1 << n); bit++){
                long double pp = p;
                int time = 0;
                for(int i = 0; i < n; i++){
                    if(bit >> i & 1){
                        time += T[i];
                        pp *= (long double)(A[i] - k) / (long double)(P[i] - k);
                    }
                    else{
                        time += S[i];
                        pp *= (long double)(P[i] - k - (A[i] - k)) / (long double)(P[i] - k);
                        A[i]++;
                    }
                }
                if(pp != 0){
                    if(time <= 60){
                        mi = min(mi, day);
                        ave += (long double) day * pp;
                    }
                    else NP[f(A)] += pp;
                }

                for(int i = 0; i < n; i++){
                    if(!(bit >> i & 1)) A[i]--;
                }
            }
        }
        PP.swap(NP);
        ma = max(ma, day);
        day++;
    }
    cout << mi << " " << ma << " " << ave << endl;
    return 0;
}
0