結果

問題 No.173 カードゲーム(Medium)
ユーザー rpy3cpprpy3cpp
提出日時 2015-03-27 00:50:58
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,231 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 81,180 KB
最終ジャッジ日時 2023-09-11 10:38:56
合計ジャッジ時間 6,732 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
77,816 KB
testcase_01 AC 681 ms
80,536 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 2,573 ms
79,876 KB
testcase_06 AC 2,008 ms
79,244 KB
testcase_07 AC 1,760 ms
79,060 KB
testcase_08 AC 1,728 ms
79,124 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N, Pa, Pb = input().split()
    N = int(N)
    Pa = float(Pa)
    Pb = float(Pb)
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    return N, Pa, Pb, A, B

def solve(N, Pa, Pb, A, B):
    Nsim = 10**6
    Awin = 0
    for i in range(Nsim):
        if simulate(N, Pa, Pb, A[:], B[:]):
            Awin += 1
    return Awin / Nsim

import random
def simulate(N, Pa, Pb, A, B):
    scoreA = 0
    scoreB = 0
    for i in range(N-1, 0, -1):
        ra = random.random()
        rb = random.random()
        if ra < Pa:
            pa = A[-1]
            del A[-1]
        else:
            ia = random.randrange(0, i)
            pa = A[ia]
            del A[ia]
        if rb < Pb:
            pb = B[-1]
            del B[-1]
        else:
            ib = random.randrange(0, i)
            pb = B[ib]
            del B[ib]
        if pa > pb:
            scoreA += pa + pb
        elif pa < pb:
            scoreB += pa + pb
    pa = A[0]
    pb = B[0]
    if pa > pb:
        scoreA += pa + pb
    elif pa < pb:
        scoreB += pa + pb
    return scoreA > scoreB

N, Pa, Pb, A, B = read_data()
print(solve(N, Pa, Pb, A, B))
0