def read_data(): N, Pa, Pb = input().split() N = int(N) Pa = float(Pa) Pb = float(Pb) A = list(map(int, input().split())) B = list(map(int, input().split())) A.sort(reverse=True) B.sort(reverse=True) return N, Pa, Pb, A, B def solve(N, Pa, Pb, A, B): Nsim = 10**6 Awin = 0 for i in range(Nsim): if simulate(N, Pa, Pb, A[:], B[:]): Awin += 1 return Awin / Nsim import random def simulate(N, Pa, Pb, A, B): scoreA = 0 scoreB = 0 for i in range(N-1, 0, -1): ra = random.random() rb = random.random() if ra < Pa: pa = A[-1] del A[-1] else: ia = random.randrange(0, i) pa = A[ia] del A[ia] if rb < Pb: pb = B[-1] del B[-1] else: ib = random.randrange(0, i) pb = B[ib] del B[ib] if pa > pb: scoreA += pa + pb elif pa < pb: scoreB += pa + pb pa = A[0] pb = B[0] if pa > pb: scoreA += pa + pb elif pa < pb: scoreB += pa + pb return scoreA > scoreB N, Pa, Pb, A, B = read_data() print(solve(N, Pa, Pb, A, B))