# frozen_string_literal: true class Array # rubocop:todo Style/Documentation def judge count { |b, a| a > b } * 2 > size end def probability Rational(count(true), size).to_f end end def solve B.permutation.map { _1.zip(A).judge }.probability end N = gets.to_i A, B = 2.times.map { gets.split.map(&:to_i) } puts solve