結果

問題 No.173 カードゲーム(Medium)
ユーザー mkawa2mkawa2
提出日時 2020-01-26 18:47:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,655 ms / 3,000 ms
コード長 900 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 8,976 KB
最終ジャッジ日時 2023-10-12 12:19:04
合計ジャッジ時間 19,199 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
8,920 KB
testcase_01 AC 331 ms
8,948 KB
testcase_02 AC 2,391 ms
8,976 KB
testcase_03 AC 2,401 ms
8,920 KB
testcase_04 AC 2,363 ms
8,844 KB
testcase_05 AC 2,175 ms
8,924 KB
testcase_06 AC 2,034 ms
8,828 KB
testcase_07 AC 1,960 ms
8,968 KB
testcase_08 AC 1,955 ms
8,844 KB
testcase_09 AC 2,655 ms
8,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
def LI(): return list(map(int, sys.stdin.readline().split()))

from random import *
def main():
    def game(xx,yy):
        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]
        #print(xx,yy,m,i,j)

    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=100000
    win=0
    for _ in range(loop):
        if game(aa[:],bb[:]):win+=1
    print(win/loop)


main()
0