#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mp make_pair #define mt make_tuple #define pb push_back #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pii; const int INF = 1 << 29; const double EPS = 1e-9; const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int N; double Pa, Pb; vector A, B; bool usedA[22]; bool usedB[22]; unsigned long xor128(void) { static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123; unsigned long t; t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } int getMinA(const vector &array) { for (int i = 0; i < array.size(); i++) { if (usedA[i]) continue; usedA[i] = true; return array[i]; } return 0; } int getMinB(const vector &array) { for (int i = 0; i < array.size(); i++) { if (usedB[i]) continue; usedB[i] = true; return array[i]; } return 0; } int main() { cin >> N >> Pa >> Pb; A.resize(N); B.resize(N); for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); for (int i = 0; i < N; i++) { cin >> B[i]; } sort(B.begin(), B.end()); int res = 0; for (int i = 0; i <= 100000; i++) { memset(usedA, false, sizeof(usedA)); memset(usedB, false, sizeof(usedB)); int sumA, sumB; sumA = sumB = 0; random_device rd; mt19937 gen(rd()); for (int i = 0; i < N; i++) { int cardA, cardB; cardA = cardB = 0; if (i != N - 1) { uniform_real_distribution randomDoubleDistribution(0.0, 1.0); double proA = randomDoubleDistribution(gen); double proB = randomDoubleDistribution(gen); if (proA <= Pa) { cardA = getMinA(A); } else { vector tmpA; for (int k = 0; k < N; k++) { if (usedA[k]) continue; tmpA.push_back(mp(k, A[k])); } pii pa = tmpA[xor128() % tmpA.size()]; usedA[pa.first] = true; cardA = pa.second; } if (proB <= Pb) { cardB = getMinB(B); } else { vector tmpB; for (int k = 0; k < N; k++) { if (usedB[k]) continue; tmpB.push_back(mp(k, B[k])); } pii pb = tmpB[xor128() % tmpB.size()]; usedB[pb.first] = true; cardB = pb.second; } }else{ cardA = getMinA(A); cardB = getMinB(B); } if (cardA > cardB){ sumA += (cardA + cardB); }else if(cardB > cardA){ sumB += (cardA + cardB); } } if (sumA > sumB){ res++; } } printf("%.9lf\n", (double)res / 100000); return 0; }