結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  not_522 | 
| 提出日時 | 2015-07-28 06:54:28 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,138 bytes | 
| コンパイル時間 | 1,375 ms | 
| コンパイル使用メモリ | 165,136 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-25 03:34:00 | 
| 合計ジャッジ時間 | 2,105 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline T gcd(T a, T b) {
  return __gcd(a, b);
}
template<typename T> inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template<typename T> inline T floor(T a, T b) {
  return a / b * b <= a ? a / b : a / b - 1;
}
template<typename T> inline T ceil(T a, T b) {
  return floor(a + b - 1, b);
}
template<typename T> inline T round(T a, T b) {
  return floor(a + b / 2);
}
template<typename T> inline T mod(T a, T b) {
  return a - floor(a, b) * b;
}
template<typename T> inline T factorial(T n) {
  return n <= 1 ? 1 : factorial(n - 1) * n;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int& i : a) cin >> i;
  for (int& i : b) cin >> i;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int c = 0;
  do {
    do {
      int r = 0;
      for (int i = 0; i < n; ++i) {
        if (a[i] > b[i]) ++r;
        if (a[i] < b[i]) --r;
      }
      if (r > 0) ++c;
    } while (next_permutation(b.begin(), b.end()));
  } while (next_permutation(a.begin(), a.end()));
  cout << fixed << setprecision(15) << c / pow(factorial(n), 2);
}
            
            
            
        