結果

問題 No.133 カードゲーム
ユーザー mizocodermizocoder
提出日時 2018-08-25 20:39:07
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 327 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 11,528 KB
実行使用メモリ 15,696 KB
最終ジャッジ日時 2023-09-09 03:20:34
合計ジャッジ時間 3,249 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,428 KB
testcase_01 AC 82 ms
15,380 KB
testcase_02 AC 82 ms
15,524 KB
testcase_03 AC 81 ms
15,296 KB
testcase_04 AC 83 ms
15,440 KB
testcase_05 AC 83 ms
15,476 KB
testcase_06 AC 83 ms
15,416 KB
testcase_07 AC 83 ms
15,400 KB
testcase_08 AC 81 ms
15,460 KB
testcase_09 AC 80 ms
15,544 KB
testcase_10 AC 83 ms
15,544 KB
testcase_11 AC 81 ms
15,660 KB
testcase_12 AC 80 ms
15,388 KB
testcase_13 AC 83 ms
15,420 KB
testcase_14 AC 81 ms
15,664 KB
testcase_15 AC 81 ms
15,604 KB
testcase_16 AC 80 ms
15,616 KB
testcase_17 AC 81 ms
15,132 KB
testcase_18 AC 83 ms
15,556 KB
testcase_19 AC 83 ms
15,652 KB
testcase_20 AC 81 ms
15,696 KB
testcase_21 AC 80 ms
15,660 KB
testcase_22 AC 82 ms
15,544 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

ord = [*(0..N-1)].permutation.to_a

count = 0

ord.each do |ord_a|
	ord.each do |ord_b|
		win = 0
		
		N.times do |i|
			win += 1 if A[ord_a[i]] > B[ord_b[i]]
		end
		
		count += 1 if win > N/2
	end
end

puts (count.to_f / ((1..N).inject(:*) ** 2)).round(6)
0