結果

問題 No.2389 Cheating Code Golf
ユーザー 👑 獅子座じゃない人獅子座じゃない人
提出日時 2023-06-20 00:52:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,745 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 182,108 KB
実行使用メモリ 8,744 KB
最終ジャッジ日時 2023-10-10 01:13:32
合計ジャッジ時間 9,632 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,744 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 25 ms
4,368 KB
testcase_03 AC 755 ms
4,372 KB
testcase_04 AC 1,129 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 10 ms
4,372 KB
testcase_08 AC 292 ms
4,368 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 1 ms
4,372 KB
testcase_13 AC 10 ms
4,368 KB
testcase_14 AC 3 ms
4,372 KB
testcase_15 AC 2 ms
4,372 KB
testcase_16 AC 138 ms
4,372 KB
testcase_17 AC 2 ms
4,368 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 AC 2 ms
4,372 KB
testcase_20 AC 1 ms
4,372 KB
testcase_21 AC 2 ms
4,368 KB
testcase_22 AC 2 ms
4,368 KB
testcase_23 AC 2 ms
4,372 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,372 KB
testcase_26 AC 1 ms
4,368 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")

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

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> p(n);
    for(int i=0;i<n;++i){
        cin >> a[i] >> b[i] >> p[i];
    }
    vector<vector<double>> dp_(1<<n,vector<double>(2));
    vector<int> memo(1<<n);
    for(int i=0;i<(1<<n);++i){
        for(int j=0;j<2;++j){
            for(int k=0;k<n;++k){
                if(j){
                    if((i>>k)&1){
                        if((dp_[i-(1<<k)][j]+1.0/b[k])/p[k]+dp_[i][j-1]*(1.0-1.0/p[k])>dp_[i][j]){
                            memo[i]=k;
                        }
                        dp_[i][j]=max((dp_[i-(1<<k)][j]+1.0/b[k])/p[k]+dp_[i][j-1]*(1.0-1.0/p[k]),dp_[i][j]);
                    }
                } else if((i>>k)&1){
                    dp_[i][j]=max(dp_[i-(1<<k)][j]+1.0/a[k],dp_[i][j]);
                }
            }
        }
    }
    vector<int> pos(n);
    for(int i=0;i<n;++i){
        pos[i]=i;
    }
    do {
        bool ok=true;
        int cur=0;
        for(int i=0;i<n;++i){
            cur|=(1<<pos[i]);
            if(memo[cur]!=pos[i]){
                ok=false;
                break;
            }
        }
        if(ok){
            break;
        }
    } while(next_permutation(pos.begin(),pos.end()));
    vector<vector<double>> dp(n+1,vector<double>(m+1));
    for(int i=0;i<n;++i){
        for(int j=0;j<=m;++j){
            dp[i+1][j]=max(dp[i][j]+1.0/a[pos[i]],dp[i+1][j]);
            if(j){
                dp[i+1][j]=max((dp[i][j]+1.0/b[pos[i]])/p[pos[i]]+dp[i+1][j-1]*(1.0-1.0/p[pos[i]]),dp[i+1][j]);
            }
        }
    }
    cout << setprecision(15) << dp[n][m] << endl;
    return 0;
}
0