結果

問題 No.133 カードゲーム
ユーザー yasshi_noyasshi_no
提出日時 2020-09-06 11:32:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 204 ms / 5,000 ms
コード長 801 bytes
コンパイル時間 1,309 ms
コンパイル使用メモリ 86,688 KB
実行使用メモリ 78,672 KB
最終ジャッジ日時 2023-08-19 13:45:04
合計ジャッジ時間 5,829 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
77,612 KB
testcase_01 AC 131 ms
77,632 KB
testcase_02 AC 133 ms
77,608 KB
testcase_03 AC 129 ms
77,616 KB
testcase_04 AC 128 ms
77,340 KB
testcase_05 AC 204 ms
78,556 KB
testcase_06 AC 135 ms
78,648 KB
testcase_07 AC 140 ms
78,476 KB
testcase_08 AC 134 ms
77,752 KB
testcase_09 AC 133 ms
77,624 KB
testcase_10 AC 137 ms
78,628 KB
testcase_11 AC 139 ms
78,672 KB
testcase_12 AC 138 ms
78,532 KB
testcase_13 AC 137 ms
77,840 KB
testcase_14 AC 133 ms
77,664 KB
testcase_15 AC 131 ms
77,716 KB
testcase_16 AC 135 ms
78,608 KB
testcase_17 AC 143 ms
78,520 KB
testcase_18 AC 144 ms
78,348 KB
testcase_19 AC 136 ms
78,604 KB
testcase_20 AC 142 ms
78,468 KB
testcase_21 AC 138 ms
78,480 KB
testcase_22 AC 139 ms
78,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()
    b = LI()
    a_per = list(itertools.permutations(a))
    b_per = list(itertools.permutations(b))
    all_game = math.factorial(n)**2
    cnt_game = 0
    for acards in a_per:
        for bcards in b_per:
            acnt = 0
            for acard, bcard in zip(acards, bcards):
                if acard>bcard:
                    acnt+=1
            bcnt = n-acnt
            if acnt>bcnt:
                cnt_game+=1
    ans = cnt_game/all_game
    print(ans)

main()
0