#![allow(unused_macros)] #![allow(dead_code)] #![allow(unused_imports)] use crate::lib::Scanner; use itertools::Itertools; use std::collections::*; const U_INF: usize = 1 << 60; const I_INF: isize = 1 << 60; fn main() { let mut sc = Scanner::new(); let n = sc.next_usize(); let a = (0..n).map(|_| sc.next_usize()).collect_vec(); let b = (0..n).map(|_| sc.next_usize()).collect_vec(); let mut win = 0; let mut sum = 0; for c in (0..n).permutations(n) { for d in (0..n).permutations(n) { let mut score = 0; for i in 0..n { if a[c[i]] > b[d[i]] { score += 1; } else { score -= 1; } } if score > 0 { win += 1; } sum += 1; } } println!("{}", win as f64 / sum as f64); } pub mod lib { pub struct Scanner { buf: std::collections::VecDeque, } impl Scanner { pub fn new() -> Self { Self { buf: std::collections::VecDeque::new(), } } fn scan_line(&mut self) { let mut flag = 0; while self.buf.is_empty() { let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); let mut iter = s.split_whitespace().peekable(); if iter.peek().is_none() { if flag >= 5 { panic!("There is no input!"); } flag += 1; continue; } for si in iter { self.buf.push_back(si.to_string()); } } } pub fn next(&mut self) -> T { self.scan_line(); self.buf .pop_front() .unwrap() .parse() .unwrap_or_else(|_| panic!("Couldn't parse!")) } pub fn next_usize(&mut self) -> usize { self.next() } pub fn next_isize(&mut self) -> isize { self.next() } pub fn next_chars(&mut self) -> Vec { self.next::().chars().collect() } pub fn next_string(&mut self) -> String { self.next() } pub fn next_char(&mut self) -> char { self.next() } pub fn next_float(&mut self) -> f64 { self.next() } } }