結果

問題 No.2389 Cheating Code Golf
ユーザー 👑 MizarMizar
提出日時 2023-07-20 12:14:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 75,764 KB
最終ジャッジ日時 2023-10-20 13:17:01
合計ジャッジ時間 6,626 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,452 KB
testcase_01 AC 39 ms
53,452 KB
testcase_02 AC 85 ms
75,760 KB
testcase_03 AC 114 ms
75,764 KB
testcase_04 AC 121 ms
75,760 KB
testcase_05 AC 58 ms
66,212 KB
testcase_06 AC 39 ms
53,452 KB
testcase_07 AC 68 ms
70,900 KB
testcase_08 AC 90 ms
75,760 KB
testcase_09 AC 40 ms
53,452 KB
testcase_10 AC 48 ms
62,108 KB
testcase_11 AC 65 ms
70,408 KB
testcase_12 AC 40 ms
53,452 KB
testcase_13 AC 86 ms
75,760 KB
testcase_14 AC 71 ms
72,472 KB
testcase_15 AC 47 ms
59,728 KB
testcase_16 AC 83 ms
75,760 KB
testcase_17 AC 40 ms
53,452 KB
testcase_18 AC 68 ms
70,544 KB
testcase_19 AC 39 ms
53,452 KB
testcase_20 AC 47 ms
59,732 KB
testcase_21 AC 62 ms
68,320 KB
testcase_22 AC 50 ms
62,048 KB
testcase_23 AC 40 ms
53,452 KB
testcase_24 AC 66 ms
68,296 KB
testcase_25 AC 61 ms
68,324 KB
testcase_26 AC 53 ms
64,248 KB
testcase_27 AC 72 ms
72,964 KB
testcase_28 AC 65 ms
68,300 KB
testcase_29 AC 55 ms
64,276 KB
testcase_30 AC 87 ms
75,760 KB
testcase_31 AC 60 ms
66,232 KB
testcase_32 AC 39 ms
53,452 KB
testcase_33 AC 40 ms
53,452 KB
testcase_34 AC 71 ms
72,940 KB
testcase_35 AC 64 ms
68,296 KB
testcase_36 AC 85 ms
75,760 KB
testcase_37 AC 55 ms
66,328 KB
testcase_38 AC 93 ms
75,760 KB
testcase_39 AC 40 ms
53,452 KB
testcase_40 AC 48 ms
62,108 KB
testcase_41 AC 51 ms
62,084 KB
testcase_42 AC 56 ms
64,152 KB
testcase_43 AC 40 ms
53,452 KB
testcase_44 AC 49 ms
62,108 KB
testcase_45 AC 88 ms
75,760 KB
testcase_46 AC 80 ms
75,760 KB
testcase_47 AC 39 ms
53,452 KB
testcase_48 AC 62 ms
68,284 KB
testcase_49 AC 67 ms
72,388 KB
testcase_50 AC 40 ms
53,452 KB
testcase_51 AC 65 ms
70,360 KB
testcase_52 AC 62 ms
68,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
ABP = [[1./v for v in map(int,input().split())] for _ in range(N)]
dp = [-float('inf')] * 4096
full_bit = (1 << N) - 1
for _ in range(M + 1):
    ndp = dp.copy()
    ndp[0] = 0.
    for i in range(1, N + 1):
        bi = (1 << i) - 1
        while bi <= full_bit:
            s = 0.
            pi = bi
            while pi > 0:
                pbit = pi & -pi
                pidx = (pbit - 1).bit_length()
                dpi = bi ^ pbit
                a, b, p = ABP[pidx]
                s = max(s, ndp[dpi] + a, (ndp[dpi] + b) * p + dp[bi] * (1. - p))
                pi &= pi - 1
            ndp[bi] = max(ndp[bi], s)
            x = bi & -bi
            y = bi + x
            bi = ((bi & ~y) >> x.bit_length()) | y
    dp = ndp
print(dp[full_bit])
0