結果

問題 No.173 カードゲーム(Medium)
ユーザー 👑 rin204rin204
提出日時 2023-11-23 19:27:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,043 ms / 3,000 ms
コード長 1,030 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 84,536 KB
最終ジャッジ日時 2023-11-23 19:27:38
合計ジャッジ時間 23,709 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,042 ms
77,792 KB
testcase_01 AC 2,041 ms
83,548 KB
testcase_02 AC 2,042 ms
82,068 KB
testcase_03 AC 2,042 ms
84,536 KB
testcase_04 AC 2,041 ms
83,768 KB
testcase_05 AC 2,042 ms
82,300 KB
testcase_06 AC 2,041 ms
81,452 KB
testcase_07 AC 2,043 ms
80,040 KB
testcase_08 AC 2,040 ms
79,784 KB
testcase_09 AC 2,040 ms
84,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import time
import random

n, pa, pb = map(float, input().split())
n = int(n)
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
B.sort()

nume = 0
deno = 0
start = time.time()
while time.time() - start < 2.0:
    score = 0
    remA = [True] * n
    remB = [True] * n
    for i in range(n):
        if i == n - 1:
            WA = [1 if tf else 0 for tf in remA]
            WB = [1 if tf else 0 for tf in remB]
        else:
            pa_ = (1.0 - pa) / (n - i - 1)
            pb_ = (1.0 - pb) / (n - i - 1)
            WA = [pa_ if tf else 0 for tf in remA]
            WB = [pb_ if tf else 0 for tf in remB]
            WA[remA.index(True)] = pa
            WB[remB.index(True)] = pb
        a = random.choices(range(n), WA)[0]
        b = random.choices(range(n), WB)[0]
        if A[a] > B[b]:
            score += A[a] + B[b]
        else:
            score -= A[a] + B[b]
        remA[a] = False
        remB[b] = False
    if score > 0:
        nume += 1
    deno += 1

print(nume / deno)
0