結果

問題 No.173 カードゲーム(Medium)
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2024-02-25 00:53:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,062 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 80,544 KB
最終ジャッジ日時 2024-02-25 00:53:46
合計ジャッジ時間 28,950 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,551 ms
77,320 KB
testcase_01 AC 2,550 ms
79,328 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2,553 ms
79,416 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2,552 ms
80,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys, math, random, time

# input = sys.stdin.readline
start = time.time()

N, pa, pb = input().split()
N = int(N)
pa = float(pa)
pb = float(pb)
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cnt = 0
win = 0
A.sort()
B.sort()


def f():

    X = deque(A[:])
    Y = deque(B[:])

    a = 0
    b = 0
    while X:
        if len(X) == 1:
            if X[0] > Y[0]:
                a += 1
            elif X[0] < Y[0]:
                b += 1
            break

        if random.random() < pa:
            vx = X.popleft()
        else:
            vx = X[random.randint(1, len(X) - 1)]
            X.remove(vx)
        if random.random() < pb:
            vy = Y.popleft()
        else:
            vy = Y[random.randint(1, len(Y) - 1)]
            Y.remove(vy)
        if vx > vy:
            a += 1
        if vx < vy:
            b += 1
    return a > b


while time.time() - start < 2.5:

    win += f()
    cnt += 1
print(win / cnt)
0