結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-07-30 00:59:14 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,189 bytes | 
| コンパイル時間 | 2,028 ms | 
| コンパイル使用メモリ | 173,756 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-30 00:59:18 | 
| 合計ジャッジ時間 | 3,107 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pint = pair<int, int>;
constexpr double PI = 3.141592653589793;
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr ll INF = 1LL << 60;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
#define vec2d(T, name, n, m, ini) vector<vector<T>> name(n, vector<T>(m, ini))
#define REP(i, e) rep(i, 0, e)
#define rep(i, s, e) for (ll i = s; i < (e); ++i)
#define rrep(i, s, e) for (ll i = s; i >= (e); --i)
#define all(x) (x).begin(), (x).end()
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];
  sort(all(a)), sort(all(b));
  double aWin = 0, cnt = 0;
  do {
      auto bCopy = b;
      do {
          ++cnt;
          int aTmp = 0, bTmp = 0;
          REP(i, n) {
              if (a[i] > bCopy[i]) ++aTmp;
              else ++bTmp;
          }
          if (aTmp > bTmp) ++aWin;
      } while (next_permutation(all(bCopy)));
  } while (next_permutation(all(a)));
  cout << fixed << setprecision(10) << aWin / cnt << "\n";
  return 0;
}
            
            
            
        