結果

問題 No.173 カードゲーム(Medium)
ユーザー mkawa2
提出日時 2020-01-26 18:40:35
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 2,504 ms / 3,000 ms
コード長 1,475 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-09-14 11:13:11
合計ジャッジ時間 18,053 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

from random import *
def main():
    def game(xx,yy,sx=0,sy=0):
        m=len(xx)
        if m==1:
            if xx[0]>yy[0]:return sx+xx[0]+yy[0]>sy
            else:return sx>sy+xx[0]+yy[0]
        if randrange(1000)<pa:i=0
        else:i=randrange(1,m)
        if randrange(1000)<pb:j=0
        else:j=randrange(1,m)
        #print(xx,yy,m,i,j)
        if xx[i]>yy[j]:return game(xx[:i]+xx[i+1:],yy[:j]+yy[j+1:],sx+xx[i]+yy[j],sy)
        else:return game(xx[:i]+xx[i+1:],yy[:j]+yy[j+1:],sx,sy+xx[i]+yy[j])

    n,pa,pb=input().split()
    pa=int(pa[2:])
    pb=int(pb[2:])
    aa=LI()
    bb=LI()
    aa.sort()
    bb.sort()
    loop=50000
    win=0
    for _ in range(loop):
        if game(aa[:],bb[:]):win+=1
    print(win/loop)


main()
0