結果

問題 No.174 カードゲーム(Hard)
ユーザー convexineqconvexineq
提出日時 2020-12-15 22:07:41
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 64,440 KB
最終ジャッジ日時 2023-10-20 06:48:04
合計ジャッジ時間 1,564 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,476 KB
testcase_01 AC 34 ms
53,484 KB
testcase_02 AC 50 ms
64,440 KB
testcase_03 AC 51 ms
64,440 KB
testcase_04 AC 51 ms
64,440 KB
testcase_05 AC 50 ms
64,440 KB
testcase_06 AC 52 ms
64,440 KB
testcase_07 AC 50 ms
64,440 KB
testcase_08 AC 51 ms
64,440 KB
testcase_09 AC 51 ms
64,440 KB
testcase_10 AC 40 ms
53,488 KB
testcase_11 AC 35 ms
53,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def get(n,p):
    res = [[0.0]*n for _ in range(n)]
    for j in range(n):
        dp = [0.0]*n # i 回目, j が k 枚目
        dp[j] = 1.0
        for i in range(n-1):
            ndp = [0.0]*n
            q = (1.0-p)/(n-i-1)
            for k in range(n):
                ndp[k] += dp[k]*q*(n-i-1-k)
                if k: ndp[k-1] += dp[k]*(1.0 - q*(n-i-k))
                res[i][j] += dp[k]*(p if k==0 else q)
            dp = ndp
        res[n-1][j] = sum(dp)
    return res

n,pa,pb = input().split()
n,pa,pb = int(n), float(pa), float(pb)
a = sorted(map(int,input().split()))
b = sorted(map(int,input().split()))
ra,rb = get(n,pa),get(n,pb)
ans = 0.0
for s in range(n):
    for i,ai in enumerate(a):
        for j,bj in enumerate(b):
            if ai > bj:
                ans += ra[s][i]*rb[s][j]*(ai+bj)
print(ans)
0