#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define BET(a,b,c) ((a)<=(b)&&(b)<(c)) #define FOR(i,n) for(int i=0,i##_end=(int(n));i VI; typedef vector VVI; bool simulation(VI A, VI B, double pa, double pb, int scoreA = 0){ if(SZ(A) == 0){ return scoreA > 0; } int n = SZ(A); if(SZ(A) == 1){ return simulation(VI(), VI(), pa, pb, scoreA + (A[0] > B[0] ? A[0] + B[0] : -(A[0] + B[0]))); }else{ bool useMinA = (rand() % 1000) < pa * 1000; int targetA = 0; if(!useMinA){ targetA = rand() % (n - 1) + 1; } bool useMinB = (rand() % 1000) < pb * 1000; int targetB = 0; if(!useMinB){ targetB = rand() % (n - 1) + 1; } int a = A[targetA]; int b = B[targetB]; A.erase(A.begin() + targetA); B.erase(B.begin() + targetB); return simulation(A, B, pa, pb, scoreA + (a > b ? (a+b):-(a+b))); } } int main() { int N; double pa,pb; cin>>N>>pa>>pb; VI A(N); FOR(i,N) cin>>A[i]; VI B(N); FOR(i,N) cin>>B[i]; sort(ALL(A)); sort(ALL(B)); double cnt = 0; double all = 0 ; FOR(_,100000){ if(simulation(A, B, pa, pb)) { cnt++; } all++; } printf("%.10f\n", cnt / all); return 0; }