#include using namespace std; int N; int A[4]; int B[4]; int permA[4], permB[4]; double vicA = 0, games = 0; void permutation(int n) { for (int i = 0; i < n; i++) { permA[i] = A[i]; } do { for (int i = 0; i < n; i++) { permB[i] = B[i]; } do { double winA = 0, winB = 0; for (int j = 0; j < n; j++) { winA += (permA[j] > permB[j]); winB += (permA[j] < permB[j]); } vicA += (winA > winB); games++; } while (next_permutation(permB, permB + n)); } while (next_permutation(permA, permA + n)); return ; } int main() { cin >> N; double 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, a + N); sort(b, b + N); for (int i = 0; i < N; i++) A[i] = a[i], B[i] = b[i]; permutation(N); double pA = vicA / games; cout << pA << endl; return 0; }