結果
| 問題 |
No.173 カードゲーム(Medium)
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2020-09-14 12:28:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 564 ms / 3,000 ms |
| コード長 | 950 bytes |
| コンパイル時間 | 329 ms |
| コンパイル使用メモリ | 82,228 KB |
| 実行使用メモリ | 78,120 KB |
| 最終ジャッジ日時 | 2024-06-22 00:46:21 |
| 合計ジャッジ時間 | 4,272 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines
npapb=readline().split()
n=int(npapb[0])
pa=float(npapb[1])
pb=float(npapb[2])
a0=list(map(int, readline().split()))
b0=list(map(int, readline().split()))
a0.sort(reverse=True)
b0.sort(reverse=True)
cnt=0
import random
for _ in range(100000):
sa, sb=0, 0
a=a0[:]
b=b0[:]
for i in range(n):
if i==n-1:
if a[0]>b[0]:
sa+=a[0]+b[0]
else:
sb+=a[0]+b[0]
break
ra=random.random()
rb=random.random()
ia, ib=n-1-i, n-1-i
if ra>pa:
ia=random.randint(0, n-i-2)
if rb>pb:
ib=random.randint(0, n-i-2)
a1=a[ia]
b1=b[ib]
if a1>b1:
sa+=a1+b1
else:
sb+=a1+b1
a.pop(ia)
b.pop(ib)
if sa>sb:
cnt+=1
print(cnt/100000.0)
chocorusk