結果

問題 No.173 カードゲーム(Medium)
ユーザー maspymaspy
提出日時 2020-03-17 03:46:26
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 882 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 86,680 KB
実行使用メモリ 82,784 KB
最終ジャッジ日時 2023-08-19 11:33:07
合計ジャッジ時間 22,845 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 224 ms
78,176 KB
testcase_01 AC 666 ms
80,856 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 AC 2,909 ms
81,012 KB
testcase_05 AC 2,434 ms
81,848 KB
testcase_06 AC 2,011 ms
80,140 KB
testcase_07 AC 1,777 ms
78,924 KB
testcase_08 AC 1,729 ms
79,708 KB
testcase_09 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import random

# %%
N, PA, PB = readline().split()
N = int(N)
PA = float(PA)
PB = float(PB)
A = sorted(map(int, readline().split()))
B = sorted(map(int, readline().split()))


# %%
def select_card(A, P):
    if len(A) == 1:
        return 0
    p = random.random()
    if p < P:
        return 0
    n = len(A)
    return random.randint(1, n - 1)


# %%
def simulate(N, A, B):
    SA = 0
    SB = 0
    for _ in range(N):
        i = select_card(A, PA)
        j = select_card(B, PB)
        a = A.pop(i)
        b = B.pop(j)
        if a > b:
            SA += a + b
        elif a < b:
            SB += a + b
    return SA > SB


# %%
n_trial = 10 ** 6
win = sum(simulate(N, A[:], B[:]) for _ in range(n_trial))
print(win / n_trial)
0