結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-11-15 02:20:56 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 3,904 bytes | 
| コンパイル時間 | 3,935 ms | 
| コンパイル使用メモリ | 254,444 KB | 
| 最終ジャッジ日時 | 2025-02-08 20:22:49 | 
| ジャッジサーバーID (参考情報) | judge3 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
// using mint = modint1000000007;
// using mint = modint998244353;
typedef long long ll;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define nrep(i,n) for (int i = 1; i <= (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define pop_count(x) __builtin_popcountll(x)
using P = pair<int,int>;
#define INF 1001001001
#define LINF ((1LL<<61)-1)
#define endl "\n"
#define exist(v, x) ((v).find(x) != v.end())
#define argsort(v) sort(xy.begin(), xy.end(), [](const auto &p1, const auto &p2) { return atan2l(p1.second, p1.first) < atan2l(p2.second, p2.first);})
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }
/* DEBUG */
#define debug_bar cerr << "\033[36m" << "----------------------------------------\n" << "\033[m";
#define debug_header cerr << "\033[36m" << "[" << __FUNCTION__ << ":" << __LINE__ << "] " << "\033[m";
#define debug(...) do { debug_header; cerr << "\033[36m" << #__VA_ARGS__ << " = "; view(__VA_ARGS__); cerr << '\n' << "\033[m"; } while (0)
#define debug2(vv) do { debug_header; cerr << "\033[36m" << #vv << " = [\n"; view2d(vv); cerr << "  ]\n" << "\033[m"; } while (0)
#define debug3(vvv) do { debug_header; cerr << "\033[36m" << #vvv << " = [\n"; view3d(vvv); cerr << "  ]\n" << "\033[m"; } while (0)
void view() {}
void view(const ll& a) { if (abs(a) == LINF) { cerr << "+-"[signbit(a)] << "LINF"; } else { cerr << a; } }
template<class T> void view(const T& a) { cerr << a; }
template<class T> void view(const vector<T>& v){ cerr << "["; for (int i = 0; i < (int)v.size(); i++) { if (i) { cerr << ", "; } view(v[i]); } cerr << "]"; }
template<class T> void view(const vector<vector<T>>& vv){ cerr << "["; for (int i = 0; i < (int)vv.size(); i++) { if (i) { cerr << ", "; } view(vv[i]); } cerr << "]"; }
template<class K, class V> void view(const map<K, V>& mp){ cerr << "["; for (auto it = mp.begin(); it != mp.end(); it++) { if (it != mp.begin()) { cerr << ", "; } cerr << "("; view(it->first); cerr << ", "; view(it->second); cerr << ")"; } cerr << "]"; }
template<class T> void view2d(const vector<vector<T>>& vv){ for (int i = 0; i < (int)vv.size(); i++) { cerr << "    "; view(vv[i]); cerr << ",\n"; } }
template<class T> void view3d(const vector<vector<vector<T>>>& vvv) { for (int i = 0; i < (int)vvv.size(); i++) { for (int j = 0; j < (int)vvv[i].size(); j++) { cerr << "    " << " ["[j == 0]; view(vvv[i][j]); if (j == (int)vvv[i].size() - 1) { cerr << "]"; } cerr << ",\n"; } if (i < (int)vvv.size() - 1) { cerr << "\n"; } } }
/* 出力 */
// template <typename T> inline void print(const vector<T>& v, string s = " ") { rep(i, v.size()) cout << v[i] << (i != (int)v.size()-1 ? s : "\n"); }
template <typename T> inline void print(const vector<T>& v, string s = " ") { rep(i, v.size()) cout << v[i] << (i != (int)v.size()-1 ? s : " \n"); }
template <typename T, typename S> inline void print(const pair<T, S>& p) { cout << p.first << " " << p.second << endl; }
template <typename T> inline void print(const T& x) { cout << x << "\n"; }
inline void print(double x) { printf("%.15f\n", x); }
inline void print(bool x) { cout << (x ? "Yes" : "No") << "\n"; }
int32_t main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  vector<int> b(n);
  rep(i, n) cin >> b[i];
  sort(all(b));
  double ans = 0;
  double cnt = 0;
  do {
    do {
      cnt += 1;
      int nowa = 0, nowb = 0;
      rep(i, n) {
        if(a[i] > b[i]) nowa++;
        else if(a[i] < b[i]) nowb++;
      }
      if(nowa > nowb) ans += 1;
    } while(next_permutation(all(b)));
  } while(next_permutation(all(a)));
  print(ans / cnt);
}
            
            
            
        