#!/usr/bin/env pypy3 # -*- coding: utf-8 -*- import random MAX_TRIAL = 160000 def use_card(l, p, cards): if l == 1: return cards.pop() else: cards.sort() judge = random.random() if judge <= p: return cards.pop(0) else: return cards.pop(random.randint(1, l - 1)) def simulate(pa, pb, a_cards, b_cards): a_score = 0 b_score = 0 a_cards_copy = a_cards[:] b_cards_copy = b_cards[:] l = len(a_cards) while a_cards_copy and b_cards_copy: a_card = use_card(l, pa, a_cards_copy) b_card = use_card(l, pb, b_cards_copy) sum_card = a_card + b_card if a_card > b_card: a_score += sum_card elif b_card > a_card: b_score += sum_card l -= 1 return 1 if a_score > b_score else 0 def compute_probability(pa, pb, a_cards, b_cards, trial=MAX_TRIAL): f = lambda: simulate(pa, pb, a_cards, b_cards) return sum(f() for _ in range(trial)) / trial def main(): _, pa, pb = map(float, input().split()) a_cards = list(map(int, input().split())) b_cards = list(map(int, input().split())) print("{:.12f}".format(compute_probability(pa, pb, a_cards, b_cards))) if __name__ == '__main__': main()