結果
| 問題 | 
                            No.173 カードゲーム(Medium)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             yaoshimax
                         | 
                    
| 提出日時 | 2015-03-27 00:43:15 | 
| 言語 | PyPy2  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1,765 ms / 3,000 ms | 
| コード長 | 770 bytes | 
| コンパイル時間 | 1,961 ms | 
| コンパイル使用メモリ | 76,688 KB | 
| 実行使用メモリ | 95,608 KB | 
| 最終ジャッジ日時 | 2024-06-29 01:18:04 | 
| 合計ジャッジ時間 | 13,596 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
ソースコード
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
            
            
            
        
            
yaoshimax