import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random, core.bitop; import std.string, std.regex, std.conv, std.stdio, std.typecons; const auto rep = 10 ^^ 6; void main() { auto rd = readln.split; auto n = rd[0].to!size_t, pa = rd[1].to!real, pb = rd[2].to!real; auto ai = readln.split.map!(to!int).array; auto bi = readln.split.map!(to!int).array; ai.sort(); bi.sort(); auto r = 0; foreach (_; 0..rep) { auto wa = 0, wb = 0; auto aj = ai.dup, bj = bi.dup; foreach (i; 0..n) { int a = pickup(aj, pa); int b = pickup(bj, pb); if (a > b) wa += a + b; else wb += a + b; } if (wa > wb) r += 1; } writeln(r.to!real / rep); } int pickup(ref int[] ai, real p) { int a; if (ai.length == 1 || uniform(0.0L, 1.0L) <= p) { a = ai.front; ai = ai[1..$]; } else { auto i = uniform(1, ai.length); a = ai[i]; ai = ai[0..i] ~ ai[i+1..ai.length]; } return a; }