結果

問題 No.173 カードゲーム(Medium)
ユーザー yaoshimaxyaoshimax
提出日時 2015-03-27 00:43:15
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 1,818 ms / 3,000 ms
コード長 770 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 77,196 KB
実行使用メモリ 98,708 KB
最終ジャッジ日時 2023-09-11 10:35:19
合計ジャッジ時間 13,867 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 191 ms
97,208 KB
testcase_01 AC 393 ms
98,372 KB
testcase_02 AC 1,540 ms
98,404 KB
testcase_03 AC 1,561 ms
98,308 KB
testcase_04 AC 1,509 ms
98,036 KB
testcase_05 AC 1,366 ms
98,328 KB
testcase_06 AC 1,165 ms
98,216 KB
testcase_07 AC 1,090 ms
97,924 KB
testcase_08 AC 1,059 ms
98,216 KB
testcase_09 AC 1,818 ms
98,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

N,Pa,Pb=map(float,raw_input().split())
N=int(N)
As=map(int,raw_input().split())
Bs=map(int,raw_input().split())
As.sort()
Bs.sort()
n_win=0
for i in range(500000):
    A=[a for a in As]
    B=[b for b in Bs]
    Ascore=0
    Bscore=0
    for j in range(N):
        a=A[0]
        b=B[0]
        if len(A)==1 or random.random()<=Pa:
            del A[0]
        else:
            ai=random.randint(1,len(A)-1)
            a=A[ai]
            del A[ai]
        if len(B)==1 or random.random()<=Pb:
            del B[0]
        else:
            bi=random.randint(1,len(B)-1)
            b=B[bi]
            del B[bi]
        if a>b:
            Ascore+=a+b
        else:
            Bscore+=a+b
    if Ascore>Bscore:
        n_win+=1
print n_win*1.0/500000
0