結果

問題 No.173 カードゲーム(Medium)
コンテスト
ユーザー yaoshimax
提出日時 2015-03-27 00:43:15
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 1,607 ms / 3,000 ms
コード長 770 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 360 ms
コンパイル使用メモリ 78,040 KB
実行使用メモリ 95,884 KB
最終ジャッジ日時 2026-02-19 21:22:25
合計ジャッジ時間 14,437 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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