#include #include #include using namespace std; int main() { 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]; } int aWinGame = 0; int game = 0; vector aIndex(n); for (int i = 0; i < n; ++i) { aIndex[i] = i; } do { vector bIndex(n); for (int i = 0; i < n; ++i) { bIndex[i] = i; } do { int aWin = 0, bWin = 0; for (int turn = 0; turn < n; ++turn) { if (a[aIndex[turn]] > b[bIndex[turn]]) { ++aWin; } else if (a[aIndex[turn]] < b[bIndex[turn]]) { ++bWin; } } if (aWin > bWin) { ++aWinGame; } ++game; } while (next_permutation(bIndex.begin(), bIndex.end())); } while (next_permutation(aIndex.begin(), aIndex.end())); cout << ((double)aWinGame / (double)game) << endl; return 0; }