結果

問題 No.173 カードゲーム(Medium)
ユーザー chocoruskchocorusk
提出日時 2020-09-14 12:28:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 554 ms / 3,000 ms
コード長 950 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 87,332 KB
実行使用メモリ 79,888 KB
最終ジャッジ日時 2023-09-04 00:39:23
合計ジャッジ時間 4,621 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
77,576 KB
testcase_01 AC 232 ms
79,284 KB
testcase_02 AC 488 ms
79,592 KB
testcase_03 AC 483 ms
79,624 KB
testcase_04 AC 475 ms
79,888 KB
testcase_05 AC 380 ms
78,816 KB
testcase_06 AC 326 ms
78,684 KB
testcase_07 AC 291 ms
79,112 KB
testcase_08 AC 286 ms
78,428 KB
testcase_09 AC 554 ms
79,784 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(reverse=True)
b0.sort(reverse=True)
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=n-1-i, n-1-i
        if ra>pa:
            ia=random.randint(0, n-i-2)
        if rb>pb:
            ib=random.randint(0, n-i-2)
        a1=a[ia]
        b1=b[ib]
        if a1>b1:
            sa+=a1+b1
        else:
            sb+=a1+b1
        a.pop(ia)
        b.pop(ib)
    if sa>sb:
        cnt+=1
print(cnt/100000.0)
0