結果
問題 |
No.173 カードゲーム(Medium)
|
ユーザー |
![]() |
提出日時 | 2025-02-06 04:04:36 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 920 bytes |
コンパイル時間 | 1,752 ms |
コンパイル使用メモリ | 82,816 KB |
実行使用メモリ | 157,644 KB |
最終ジャッジ日時 | 2025-02-06 04:05:14 |
合計ジャッジ時間 | 37,171 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 TLE * 8 |
ソースコード
import random a = input().split() N = int(a[0]) PA = float(a[1]) PB = float(a[2]) A = list(map(int, input().split())) B = list(map(int, input().split())) A.sort() B.sort() def select(cards: list[int], prob: float) -> list[int]: cands = cards.copy() res = [] for i in range(len(cards)): p = random.random() if p <= prob or len(cands) == 1: res.append(cands[0]) del cands[0] else: k = random.randint(1, len(cands)-1) res.append(cands[k]) del cands[k] return res def judge(xs, ys) -> bool: fst = 0 snd = 0 for x, y in zip(xs, ys): if x > y: fst += x + y else: snd += x + y return fst > snd trials = 1_000_000 win = 0 for _ in range(trials): xs = select(A, PA) ys = select(B, PB) if judge(xs, ys): win += 1 ans = win / trials print(ans)