結果

問題 No.133 カードゲーム
コンテスト
ユーザー tk
提出日時 2020-06-17 11:54:50
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 97 ms / 5,000 ms
コード長 488 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 351 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 15,472 KB
最終ジャッジ日時 2026-03-24 20:23:09
合計ジャッジ時間 3,551 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
readline = sys.stdin.readline
from itertools import permutations
from math import factorial

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    cnt = 0
    
    for l1 in permutations(A, N):
        for l2 in permutations(B, N):
            if len([1 for a, b in zip(l1, l2) if a > b]) > N/2:
                cnt += 1
     
  
    print(cnt / (factorial(N) ** 2))

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