結果

問題 No.1151 チャレンジゲーム
ユーザー mkawa2mkawa2
提出日時 2021-06-11 01:57:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 756 ms / 2,000 ms
コード長 1,498 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 91,616 KB
最終ジャッジ日時 2023-08-20 12:39:52
合計ジャッジ時間 26,404 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,404 KB
testcase_01 AC 82 ms
71,296 KB
testcase_02 AC 102 ms
76,004 KB
testcase_03 AC 79 ms
71,532 KB
testcase_04 AC 81 ms
71,288 KB
testcase_05 AC 81 ms
71,672 KB
testcase_06 AC 81 ms
71,412 KB
testcase_07 AC 79 ms
71,312 KB
testcase_08 AC 80 ms
71,620 KB
testcase_09 AC 82 ms
71,352 KB
testcase_10 AC 81 ms
71,628 KB
testcase_11 AC 91 ms
75,832 KB
testcase_12 AC 92 ms
76,076 KB
testcase_13 AC 288 ms
80,980 KB
testcase_14 AC 305 ms
81,452 KB
testcase_15 AC 295 ms
81,056 KB
testcase_16 AC 297 ms
81,324 KB
testcase_17 AC 284 ms
81,364 KB
testcase_18 AC 281 ms
81,256 KB
testcase_19 AC 291 ms
81,096 KB
testcase_20 AC 300 ms
81,244 KB
testcase_21 AC 286 ms
81,272 KB
testcase_22 AC 284 ms
81,208 KB
testcase_23 AC 280 ms
81,076 KB
testcase_24 AC 287 ms
81,536 KB
testcase_25 AC 296 ms
81,108 KB
testcase_26 AC 297 ms
81,084 KB
testcase_27 AC 283 ms
81,348 KB
testcase_28 AC 578 ms
91,004 KB
testcase_29 AC 597 ms
90,976 KB
testcase_30 AC 683 ms
90,692 KB
testcase_31 AC 671 ms
90,520 KB
testcase_32 AC 684 ms
91,104 KB
testcase_33 AC 712 ms
90,968 KB
testcase_34 AC 756 ms
91,208 KB
testcase_35 AC 628 ms
91,616 KB
testcase_36 AC 728 ms
91,176 KB
testcase_37 AC 627 ms
91,280 KB
testcase_38 AC 631 ms
91,500 KB
testcase_39 AC 581 ms
91,528 KB
testcase_40 AC 596 ms
91,428 KB
testcase_41 AC 624 ms
90,416 KB
testcase_42 AC 581 ms
91,048 KB
testcase_43 AC 593 ms
91,340 KB
testcase_44 AC 579 ms
90,972 KB
testcase_45 AC 598 ms
91,544 KB
testcase_46 AC 590 ms
91,288 KB
testcase_47 AC 582 ms
91,256 KB
testcase_48 AC 536 ms
90,076 KB
testcase_49 AC 582 ms
90,492 KB
testcase_50 AC 589 ms
90,892 KB
testcase_51 AC 587 ms
90,776 KB
testcase_52 AC 598 ms
91,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

popcnt = lambda x: bin(x).count("1")

n = II()
aa = LI()

tot = sum(aa)
P = {}
finish = (1 << n)-1

# 初期化
for s in range(1 << n):
    t = finish ^ s
    x = sum(a for i, a in enumerate(aa) if s >> i & 1)
    y = tot-x
    P[s, t] = (x > y)*1

# DP
for used in range(finish-1, -1, -1):
    # 2人の取ったカードを合わせたのがusedで、その部分集合をsとして回す
    s = used
    while 1:
        t = used ^ s
        val = 0
        for i, ai in enumerate(aa):
            if used >> i & 1: continue
            si = s | 1 << i

            # p1を求める
            p1 = 1
            if popcnt(used) == n-1:  # 先手が最後の1枚を取った場合
                p1 = P[si, t]
            else:
                for j, aj in enumerate(aa):
                    if j == i: continue
                    if used >> j & 1: continue
                    p1 = min(p1, P[si, t | 1 << j]/aj+P[si, t]*(aj-1)/aj)

            # kを全探索する
            mn = 1  # iを固定したときのPの最小値
            for k, ak in enumerate(aa):
                if used >> k & 1: continue
                tk = t | 1 << k
                mn = min(mn, (ak*p1+(ai-1)*P[s, tk])/(ai+ak-1))

            val = max(val, mn)

        P[s, t] = val

        if s == 0: break
        s = (s-1) & used

print(P[0, 0])
0