#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_DEPRECATE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair Pii; typedef pair Pll; #define FOR(i,n) for(int i = 0; i < (n); i++) #define sz(c) ((int)(c).size()) #define ten(x) ((int)1e##x) #define tenll(x) ((ll)1e##x) // #pragma comment(linker,"/STACK:36777216") template void chmax(T& l, const T r) { l = max(l, r); } template void chmin(T& l, const T r) { l = min(l, r); } double memo[1<<20]; double choice[20][21]; int n; int popcount(ll x) { x = (x & 0x5555555555555555ULL) + ((x & 0xAAAAAAAAAAAAAAAAULL) >> 1); x = (x & 0x3333333333333333ULL) + ((x & 0xCCCCCCCCCCCCCCCCULL) >> 2); x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x & 0xF0F0F0F0F0F0F0F0ULL) >> 4); return (int)(x * 0x0101010101010101ULL >> 56); } void f(double p) { memset(memo, 0, sizeof(memo)); memset(choice, 0, sizeof(choice)); memo[(1 << n) - 1] = 1.0; for (int F = (1 << n) - 1; F > 0; F--) { int pop = popcount(F); int bit = 0; while ((F & (1 << bit)) == 0) bit++; double q = memo[F]; if (pop == 1) { memo[F ^ (1 << bit)] += q; choice[bit][n - pop] += q; } else { memo[F ^ (1 << bit)] += p * q; choice[bit][n - pop] += p * q; bit++; double r = (1 - p) / (pop - 1); for (; bit < n; bit++) { if (F & (1 << bit)) { memo[F ^ (1 << bit)] += r * q; choice[bit][n - pop] += r * q; } } } } } double a_choice[20][21], b_choice[20][21]; int main() { double pa, pb; cin >> n >> pa >> pb; vector a(n), b(n); FOR(i, n) cin >> a[i]; FOR(i, n) cin >> b[i]; sort(a.begin(), a.end()); sort(b.begin(), b.end()); f(pa); memcpy(a_choice, choice, sizeof(choice)); f(pb); memcpy(b_choice, choice, sizeof(choice)); double ans = 0; FOR(i, n) FOR(j, n) FOR(k, n) { double p = a_choice[i][k] * b_choice[j][k]; double sm = a[i] + b[j]; if (a[i] > b[j]) { ans += p * sm; } } printf("%.15lf\n",ans); }