結果

問題 No.133 カードゲーム
ユーザー 双六双六
提出日時 2020-08-26 07:31:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 664 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 62,336 KB
最終ジャッジ日時 2024-04-24 12:34:49
合計ジャッジ時間 1,890 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,144 KB
testcase_01 AC 41 ms
54,144 KB
testcase_02 AC 37 ms
53,888 KB
testcase_03 AC 37 ms
53,376 KB
testcase_04 AC 36 ms
54,016 KB
testcase_05 AC 48 ms
60,928 KB
testcase_06 AC 44 ms
62,208 KB
testcase_07 AC 45 ms
61,056 KB
testcase_08 AC 38 ms
53,376 KB
testcase_09 AC 37 ms
53,504 KB
testcase_10 AC 44 ms
61,056 KB
testcase_11 AC 51 ms
61,440 KB
testcase_12 AC 45 ms
61,824 KB
testcase_13 AC 38 ms
53,504 KB
testcase_14 AC 36 ms
53,888 KB
testcase_15 AC 39 ms
54,016 KB
testcase_16 AC 44 ms
62,080 KB
testcase_17 AC 43 ms
60,672 KB
testcase_18 AC 45 ms
62,336 KB
testcase_19 AC 46 ms
61,952 KB
testcase_20 AC 44 ms
61,568 KB
testcase_21 AC 46 ms
62,208 KB
testcase_22 AC 43 ms
61,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")
import itertools

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = getlist()
	ans = 0
	total = 1
	for i in range(1, N + 1):
		total *= i ** 2

	P1 = list(itertools.permutations(A, N))
	P2 = list(itertools.permutations(B, N))
	for i in range(len(P1)):
		for j in range(len(P2)):
			cnt = 0
			for k in range(N):
				if P1[i][k] > P2[j][k]:
					cnt += 1

			if cnt * 2 > N:
				ans += 1

	print(ans / total)



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