結果

問題 No.173 カードゲーム(Medium)
ユーザー chocoruskchocorusk
提出日時 2020-09-14 12:18:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 643 ms / 3,000 ms
コード長 924 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 87,312 KB
実行使用メモリ 79,864 KB
最終ジャッジ日時 2023-09-04 00:38:06
合計ジャッジ時間 5,144 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
77,724 KB
testcase_01 AC 226 ms
79,504 KB
testcase_02 AC 549 ms
79,792 KB
testcase_03 AC 541 ms
79,196 KB
testcase_04 AC 537 ms
79,044 KB
testcase_05 AC 435 ms
78,560 KB
testcase_06 AC 371 ms
78,408 KB
testcase_07 AC 329 ms
78,724 KB
testcase_08 AC 324 ms
78,752 KB
testcase_09 AC 643 ms
79,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

npapb=readline().split()
n=int(npapb[0])
pa=float(npapb[1])
pb=float(npapb[2])
a0=list(map(int, readline().split()))
b0=list(map(int, readline().split()))
a0.sort()
b0.sort()
cnt=0
import random
for _ in range(100000):
    sa, sb=0, 0
    a=a0[:]
    b=b0[:]
    for i in range(n):
        if i==n-1:
            if a[0]>b[0]:
                sa+=a[0]+b[0]
            else:
                sb+=a[0]+b[0]
            break
        ra=random.random()
        rb=random.random()
        ia, ib=0, 0
        if ra>pa:
            ia=random.randint(1, n-i-1)
        if rb>pb:
            ib=random.randint(1, n-i-1)
        a1=a[ia]
        b1=b[ib]
        if a1>b1:
            sa+=a1+b1
        else:
            sb+=a1+b1
        a.remove(a1)
        b.remove(b1)
    if sa>sb:
        cnt+=1
print(cnt/100000.0)
0