結果
問題 |
No.173 カードゲーム(Medium)
|
ユーザー |
![]() |
提出日時 | 2020-03-17 03:46:03 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 2,509 ms / 3,000 ms |
コード長 | 882 bytes |
コンパイル時間 | 245 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-11-29 03:55:02 |
合計ジャッジ時間 | 15,161 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#!/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 ** 5 win = sum(simulate(N, A[:], B[:]) for _ in range(n_trial)) print(win / n_trial)