結果

問題 No.173 カードゲーム(Medium)
ユーザー mkawa2mkawa2
提出日時 2020-01-26 18:49:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,348 ms / 3,000 ms
コード長 904 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 8,964 KB
最終ジャッジ日時 2023-10-12 12:20:18
合計ジャッジ時間 10,177 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
8,820 KB
testcase_01 AC 173 ms
8,964 KB
testcase_02 AC 1,196 ms
8,804 KB
testcase_03 AC 1,203 ms
8,956 KB
testcase_04 AC 1,179 ms
8,816 KB
testcase_05 AC 1,103 ms
8,760 KB
testcase_06 AC 1,021 ms
8,916 KB
testcase_07 AC 986 ms
8,772 KB
testcase_08 AC 980 ms
8,924 KB
testcase_09 AC 1,348 ms
8,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
0