#include #include #include #include using namespace std; int main(){ int N; cin >> N; vector a(N); vector b(N); for(int i = 0;i < N;i++)cin >> a[i]; for(int i = 0;i < N;i++)cin >> b[i]; sort(a.begin(),a.end()); sort(b.begin(),b.end()); vector> a_perm; vector> b_perm; do{ a_perm.push_back(a); }while(next_permutation(a.begin(),a.end())); do{ b_perm.push_back(b); }while(next_permutation(b.begin(),b.end())); int perm_num = a_perm.size(); double ans = 0; for(int i = 0;i < perm_num;i++){ for(int j = 0;j < perm_num;j++){ int a_wins = 0; for(int k = 0;k < N;k++){ if(a_perm[i][k] > b_perm[j][k])a_wins++; } if(a_wins > N/2)ans++; } } ans = ans/(perm_num*perm_num); printf("%.10lf\n",ans); }