結果

問題 No.2389 Cheating Code Golf
ユーザー erbowlerbowl
提出日時 2023-07-22 08:57:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 871 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 213,284 KB
実行使用メモリ 16,940 KB
最終ジャッジ日時 2023-10-22 07:47:50
合計ジャッジ時間 8,272 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 142 ms
7,100 KB
testcase_03 AC 871 ms
16,940 KB
testcase_04 AC 858 ms
16,940 KB
testcase_05 AC 12 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 18 ms
4,380 KB
testcase_08 AC 200 ms
7,980 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 23 ms
4,540 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 145 ms
7,100 KB
testcase_14 AC 38 ms
4,900 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 147 ms
7,180 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 25 ms
4,540 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 10 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 17 ms
4,348 KB
testcase_25 AC 10 ms
4,348 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 31 ms
4,784 KB
testcase_28 AC 15 ms
4,348 KB
testcase_29 AC 4 ms
4,348 KB
testcase_30 AC 115 ms
6,540 KB
testcase_31 AC 7 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 41 ms
5,104 KB
testcase_35 AC 9 ms
4,348 KB
testcase_36 AC 115 ms
6,540 KB
testcase_37 AC 3 ms
4,348 KB
testcase_38 AC 280 ms
9,580 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 3 ms
4,348 KB
testcase_42 AC 3 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 3 ms
4,348 KB
testcase_45 AC 236 ms
8,620 KB
testcase_46 AC 90 ms
6,060 KB
testcase_47 AC 2 ms
4,348 KB
testcase_48 AC 19 ms
4,360 KB
testcase_49 AC 38 ms
4,900 KB
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 23 ms
4,540 KB
testcase_52 AC 9 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;

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

signed main(){
    ll n,m;
    std::cin >> n>>m;
    vector<ld> a(n),b(n),p(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i]>>b[i]>>p[i];
    }
    map<pair<ll,ll>,ld> memo;
    function<ld(ll,ll)> dfs = [&](ll i, ll j){
        if(memo.find({i,j})!=memo.end())return memo[{i,j}];
        if(i==n)return (ld)0;
        ld ma = 0;
        for (int k = 0; k < n; k++) {
            if(i&(1<<k))continue;
            if(j!=0)ma = max(ma, max(
                dfs(i+(1<<k), j)+1/a[k],
                (1/p[k])*(dfs(i+(1<<k), j)+1/b[k])+(1-1/p[k])*dfs(i,j-1)
            ));
            if(j==0){
                ma = max(ma, dfs(i+(1<<k), j)+1/a[k]);
            }
        }
        return memo[{i,j}]=ma;
    };
    std::cout << setprecision(20)<<dfs(0, m) << std::endl;
}
0