結果

問題 No.173 カードゲーム(Medium)
ユーザー noko2250noko2250
提出日時 2015-04-11 09:08:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,777 ms / 3,000 ms
コード長 874 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 10,708 KB
実行使用メモリ 8,912 KB
最終ジャッジ日時 2023-09-17 19:17:41
合計ジャッジ時間 12,088 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
8,680 KB
testcase_01 AC 268 ms
8,708 KB
testcase_02 AC 1,468 ms
8,892 KB
testcase_03 AC 1,482 ms
8,872 KB
testcase_04 AC 1,443 ms
8,844 KB
testcase_05 AC 1,250 ms
8,848 KB
testcase_06 AC 1,085 ms
8,868 KB
testcase_07 AC 998 ms
8,736 KB
testcase_08 AC 989 ms
8,912 KB
testcase_09 AC 1,777 ms
8,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/c/Python34/python
# coding: utf-8
import random


def simulate(n, pa, pb, A, B):
    a = b = 0
    a += 1
    for _ in range(n):
        ra, rb = random.random(), random.random()
        i, j = -1, -1
        if ra > pa and len(A) > 1:
            i = random.randrange(len(A)-1)
        if rb > pb and len(B) > 1:
            j = random.randrange(len(B)-1)
        if A[i] > B[j]:
            a += A[i] + B[j]
        else:
            b += A[i] + B[j]
        del A[i], B[j]
    return a > b

def main():
    [n, pa, pb] = map(float, input().split())
    n = int(n)
    A = sorted(list(map(int, input().split())), reverse=True)
    B = sorted(list(map(int, input().split())), reverse=True)
    win, check = 0, 100000
    for _ in range(check):
        if simulate(n, pa, pb, A[:], B[:]):
            win += 1
    print(win/check)


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