#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x getrandvec(double p) { int i,x; vector v,r; FOR(i,N) v.push_back(i); FOR(i,N-1) { double d = rand()*1.0/RAND_MAX; if(d>N>>P[0]>>P[1]; FOR(i,N) cin>>A[i], T+=A[i]; FOR(i,N) cin>>B[i], T+=B[i]; sort(A,A+N); sort(B,B+N); srand(time(NULL)); FOR(i,100000) { tot++; vector VA,VB; VA=getrandvec(P[0]); VB=getrandvec(P[1]); //FOR(y,N) _P("%d ",VA[y]); //FOR(y,N) _P("%d ",VB[y]); x=0; FOR(y,N) if(A[VA[y]]>B[VB[y]]) x+=A[VA[y]]+B[VB[y]]; //_P("%d ",x); //_P("\n"); if(x>T/2) win++; } _P("%.12lf\n",1.0*win/tot); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }