import java.util.ArrayList; import java.util.Collections; import java.util.Random; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Random random = new Random(); int N = sc.nextInt(); double Pa = sc.nextDouble(); double Pb = sc.nextDouble(); int[] a = new int[N]; int[] b = new int[N]; for (int i = 0; i < N; i++) { a[i] = sc.nextInt(); } for (int i = 0; i < N; i++) { b[i] = sc.nextInt(); } sc.close(); int rep = 100000; int wina = 0; for (int i = 0; i < rep; i++) { int pointa = 0; int pointb = 0; ArrayList aList = new ArrayList<>(); ArrayList bList = new ArrayList<>(); for (int j = 0; j < N; j++) { aList.add(a[j]); bList.add(b[j]); } Collections.sort(aList); Collections.sort(bList); for (int j = 0; j < N; j++) { double rand_a = random.nextDouble(); double rand_b = random.nextDouble(); int card_aid = (rand_a < Pa || aList.size() == 1) ? 0 : random.nextInt(aList.size() - 1) + 1; int card_bid = (rand_b < Pb || bList.size() == 1) ? 0 : random.nextInt(bList.size() - 1) + 1; int card_a = aList.get(card_aid); aList.remove(card_aid); int card_b = bList.get(card_bid); bList.remove(card_bid); if (card_a > card_b) { pointa += card_a + card_b; } else if (card_a < card_b) { pointb += card_a + card_b; } } if (pointa > pointb) { wina++; } } System.out.println((double) wina / rep); } }