結果
| 問題 |
No.173 カードゲーム(Medium)
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-02-06 04:05:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,539 ms / 3,000 ms |
| コード長 | 918 bytes |
| コンパイル時間 | 619 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 78,968 KB |
| 最終ジャッジ日時 | 2025-02-06 04:06:04 |
| 合計ジャッジ時間 | 11,544 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
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 = 200_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)
norioc