using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProgrammingContest { class MainClass { Scanner sc; static void Main(string[] args) { new MainClass().Solve(); } void Solve() { #if DEBUG string backPath = ".."; char dirSep = System.IO.Path.DirectorySeparatorChar; string inFilePath = backPath + dirSep + backPath + dirSep + "in.txt"; sc = new Scanner(new System.IO.StreamReader(inFilePath)); #else sc = new Scanner(); #endif int n = sc.NextInt; int[] a = new int[n].Select(val => sc.NextInt).ToArray(); int[] b = new int[n].Select(val => sc.NextInt).ToArray(); int[] sel = new int[n]; for (int i = 0; i < n; i++) { sel[i] = i; } int win = 0, allCnt = 0; do { int cnt = 0; for (int i = 0; i < n; i++) { if (a[sel[i]] > b[i]) { cnt++; } } if (cnt * 2 > n) { win++; } allCnt++; //Write(ArrayToString(sel)); } while (NextPermutation(sel)); Write(1.0 * win / allCnt); } bool NextPermutation(T[] ar) where T : IComparable { int left = ar.Length - 1; Func compForCalcNextPermutation = (i, j) => { return ar[i].CompareTo(ar[j]); }; while (0 < left && compForCalcNextPermutation(left - 1, left) >= 0) { left--; } if (left == 0) { return false; } int right = ar.Length - 1; while (compForCalcNextPermutation(right, left - 1) <= 0) { right--; } Swap(ref ar[left - 1], ref ar[right]); right = ar.Length - 1; while (left < right) { Swap(ref ar[left], ref ar[right]); left++; right--; } return true; } void Write(object val) { Console.WriteLine(val.ToString()); } void Write(string format, params object[] vals) { Console.WriteLine(format, vals); } void Swap(ref T a, ref T b) { T tmp = a; a = b; b = tmp; } string ArrayToString(T[] ar, string sep = " ") { return string.Join(sep, Array.ConvertAll(ar, el => el.ToString())); } } class Scanner { Queue buffer; char[] sep; System.IO.TextReader reader; public Scanner(System.IO.TextReader reader = null) { this.buffer = new Queue(); this.sep = new char[] { ' ' }; this.reader = (reader ?? Console.In); } private void CheckBuffer() { if (this.buffer.Count == 0 && this.reader.Peek() >= 0) { string[] sreArray = this.reader.ReadLine().Split(this.sep); foreach (String elStr in sreArray) { this.buffer.Enqueue(elStr); } } } public String Next { get { this.CheckBuffer(); return this.buffer.Dequeue(); } } public int NextInt { get { return int.Parse(this.Next); } } public double NextDouble { get { return double.Parse(this.Next); } } public long NextLong { get { return long.Parse(this.Next); } } public bool IsEmpty { get { this.CheckBuffer(); return this.buffer.Count == 0; } } } }