結果

問題 No.173 カードゲーム(Medium)
ユーザー Mao-betaMao-beta
提出日時 2024-03-23 00:24:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,957 ms / 3,000 ms
コード長 1,772 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 82,196 KB
最終ジャッジ日時 2024-03-23 00:25:26
合計ジャッジ時間 33,739 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,957 ms
77,368 KB
testcase_01 AC 2,951 ms
81,532 KB
testcase_02 AC 2,952 ms
81,668 KB
testcase_03 AC 2,953 ms
81,668 KB
testcase_04 AC 2,953 ms
81,544 KB
testcase_05 AC 2,952 ms
79,996 KB
testcase_06 AC 2,951 ms
79,628 KB
testcase_07 AC 2,953 ms
78,976 KB
testcase_08 AC 2,952 ms
78,848 KB
testcase_09 AC 2,953 ms
82,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
SMI = lambda: input().split()
SLI = lambda: list(SMI())
EI = lambda m: [NLI() for _ in range(m)]


from random import randint
import time

def main():
    start = time.time()
    N, Pa, Pb = SMI()
    N = int(N)
    Pa += "0" * (5 - len(Pa))
    Pb += "0" * (5 - len(Pb))
    Pa = int(Pa.replace(".", ""))
    Pb = int(Pb.replace(".", ""))
    A = NLI()
    B = NLI()

    def trial():
        HA = A[:]
        HB = B[:]
        sa = 0
        sb = 0
        for _ in range(N):
            HA.sort()
            HB.sort()

            ar = randint(1, 1000)
            if len(HA) == 1 or ar <= Pa:
                a = HA[0]
                HA.pop(0)
            else:
                idx = randint(1, len(HA)-1)
                a = HA[idx]
                HA.pop(idx)

            br = randint(1, 1000)
            if len(HB) == 1 or br <= Pb:
                b = HB[0]
                HB.pop(0)
            else:
                idx = randint(1, len(HB) - 1)
                b = HB[idx]
                HB.pop(idx)

            if a > b:
                sa += a+b
            else:
                sb += a+b

        return sa > sb

    total = 0
    win = 0
    while time.time() - start < 2.9:
        total += 1
        win += int(trial())

    print(win / total)


if __name__ == "__main__":
    main()
0