結果

問題 No.173 カードゲーム(Medium)
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2024-02-25 00:57:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,552 ms / 3,000 ms
コード長 1,094 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 80,048 KB
最終ジャッジ日時 2024-02-25 00:58:23
合計ジャッジ時間 29,042 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,551 ms
77,068 KB
testcase_01 AC 2,551 ms
78,968 KB
testcase_02 AC 2,551 ms
79,648 KB
testcase_03 AC 2,551 ms
79,844 KB
testcase_04 AC 2,551 ms
80,040 KB
testcase_05 AC 2,551 ms
79,140 KB
testcase_06 AC 2,550 ms
78,784 KB
testcase_07 AC 2,552 ms
78,456 KB
testcase_08 AC 2,551 ms
78,724 KB
testcase_09 AC 2,551 ms
80,048 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 += X[0] + Y[0]
            elif X[0] < Y[0]:
                b += X[0] + Y[0]
            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 += vx + vy
        if vx < vy:
            b += vx + vy
    return a > b


while time.time() - start < 2.5:

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