#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define endl '\n' #define ALL(v) (v).begin(), (v).end() #define RALL(v) (v).rbegin(), (v).rend() #define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end()) typedef long long ll; typedef long double ld; typedef pair P; typedef complex comp; typedef vector< vector > matrix; struct pairhash { public: template size_t operator()(const pair &x) const { size_t seed = hash()(x.first); return hash()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2); } }; const int inf = 1e9 + 9; const ll mod = 1e9 + 7; const double eps = 1e-8; const double pi = acos(-1); int n; double p[2]; int a[2][20]; double prob[2][1<<21]; double q[2][21][21]; int bitcount(int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff); } double calc_prob(int s, int k) { if (prob[k][s] < 0) { double res = 0; if (s == 0) { for (int i = 0; i < n; i++) { res += calc_prob(1<>i)&1) l = i; for (int i = 0; i < l; i++) if (!((s>>i)&1)) res += (1.0-p[k]) * calc_prob(s|(1<>k)&1) l = k; if (c == 1) { q[i][c][l] += prob[i][j]; } else { q[i][c][l] += p[i] * prob[i][j]; for (int k = 0; k < l; k++) if ((j>>k)&1) q[i][c][k] += (1.0-p[i]) * prob[i][j] / (c-1); } } } double res = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { if (a[0][j] > a[1][k]) { res += q[0][i][j] * q[1][i][k] * (a[0][j] + a[1][k]); } } } } return res; } void input() { cin >> n >> p[0] >> p[1]; for (int i = 0; i < 2; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); input(); cout << solve() << endl; }