結果
問題 |
No.173 カードゲーム(Medium)
|
ユーザー |
![]() |
提出日時 | 2020-01-26 18:49:47 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,683 ms / 3,000 ms |
コード長 | 904 bytes |
コンパイル時間 | 424 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-09-14 11:14:52 |
合計ジャッジ時間 | 12,847 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
import sys sys.setrecursionlimit(10 ** 6) def LI(): return list(map(int, sys.stdin.readline().split())) from random import * def game(xx, yy, n, pa, pb): sx = sy = 0 for _ in range(n - 1): m = len(xx) if randrange(1000) < pa: i = m - 1 else: i = randrange(m - 1) if randrange(1000) < pb: j = m - 1 else: j = randrange(m - 1) if xx[i] > yy[j]: sx += xx[i] + yy[j] else: sy += xx[i] + yy[j] del xx[i] del yy[j] if xx[0] > yy[0]: return sx + xx[0] + yy[0] > sy else: return sx > sy + xx[0] + yy[0] def main(): n, pa, pb = input().split() n = int(n) pa = int(pa[2:]) pb = int(pb[2:]) aa = LI() bb = LI() aa.sort(reverse=True) bb.sort(reverse=True) loop = 50000 win = 0 for _ in range(loop): if game(aa[:], bb[:], n, pa, pb): win += 1 print(win / loop) main()