#include #define err(args...) {} #ifdef DEBUG #include "_debug.cpp" #endif using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n), 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()); int win = 0, games = 0; do { sort(b.begin(), b.end()); do { int a_score = 0, b_score = 0; for(int i = 0; i < n; i++) { a_score += a[i] > b[i]; b_score += b[i] > a[i]; } win += a_score > b_score; games++; } while(next_permutation(b.begin(), b.end())); } while(next_permutation(a.begin(), a.end())); cout << double(win) / games << endl; return 0; }