結果

問題 No.173 カードゲーム(Medium)
ユーザー mkawa2mkawa2
提出日時 2020-01-26 18:40:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,955 ms / 3,000 ms
コード長 1,475 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 9,336 KB
最終ジャッジ日時 2023-10-12 12:18:43
合計ジャッジ時間 14,396 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
9,164 KB
testcase_01 AC 215 ms
9,220 KB
testcase_02 AC 1,764 ms
9,176 KB
testcase_03 AC 1,759 ms
9,216 KB
testcase_04 AC 1,729 ms
9,264 KB
testcase_05 AC 1,632 ms
9,216 KB
testcase_06 AC 1,506 ms
9,336 KB
testcase_07 AC 1,477 ms
9,316 KB
testcase_08 AC 1,460 ms
9,332 KB
testcase_09 AC 1,955 ms
9,260 KB
権限があれば一括ダウンロードができます

ソースコード

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