結果

問題 No.133 カードゲーム
ユーザー kakukakujirorikakukakujirori
提出日時 2021-08-09 17:48:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 481 ms / 5,000 ms
コード長 1,070 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,924 KB
実行使用メモリ 42,320 KB
最終ジャッジ日時 2023-10-21 15:33:36
合計ジャッジ時間 13,811 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 415 ms
42,320 KB
testcase_01 AC 414 ms
42,320 KB
testcase_02 AC 416 ms
42,320 KB
testcase_03 AC 413 ms
42,320 KB
testcase_04 AC 408 ms
42,320 KB
testcase_05 AC 419 ms
42,320 KB
testcase_06 AC 418 ms
42,320 KB
testcase_07 AC 410 ms
42,320 KB
testcase_08 AC 417 ms
42,320 KB
testcase_09 AC 481 ms
42,320 KB
testcase_10 AC 417 ms
42,320 KB
testcase_11 AC 419 ms
42,320 KB
testcase_12 AC 417 ms
42,320 KB
testcase_13 AC 416 ms
42,320 KB
testcase_14 AC 417 ms
42,320 KB
testcase_15 AC 424 ms
42,320 KB
testcase_16 AC 438 ms
42,320 KB
testcase_17 AC 432 ms
42,320 KB
testcase_18 AC 425 ms
42,320 KB
testcase_19 AC 421 ms
42,320 KB
testcase_20 AC 418 ms
42,320 KB
testcase_21 AC 417 ms
42,320 KB
testcase_22 AC 420 ms
42,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np
#from numba import njit, b1, i1, i4, i8, f8, jitclass
sys.setrecursionlimit(10**9)
from itertools import permutations

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def input(): return sys.stdin.readline().strip()
#"""
def from_read(dtype=np.int64):
    return np.fromstring(read().decode(), dtype=dtype, sep=' ')

def from_readline(dtype=np.int64):
    return np.fromstring(readline().decode(), dtype=dtype, sep=' ')
#"""

        
#@njit("(i8,i8,i8,i8[:],i8[:],)", cache=True)
def main(N, A, B):
    total = 1
    for i in range(1, N + 1): total *= i
    total *= total
    ans = 0
    for a in permutations(A, N):
        for b in permutations(B, N):
            win = 0
            for aa, bb in zip(a, b):
                win += 1 if aa > bb else 0
            ans += 1 if win > N // 2 else 0
    print(ans / total)
            

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    main(N, A, B)
0