結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-03-24 21:24:33 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,508 bytes | 
| コンパイル時間 | 2,297 ms | 
| コンパイル使用メモリ | 200,504 KB | 
| 最終ジャッジ日時 | 2025-02-11 16:55:41 | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
using vvl = vector<vector<long long>>; using vs = vector<string>;
using pl = pair<long long, long long>;
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}
template<class T>using rp_queue=priority_queue<T,vector<T>,greater<T>>;
template <typename T> T gcd(T a, T b) {if (b == 0)return a; else return gcd(b, a % b);}
template <typename T> inline T lcm(T a, T b) {return a /gcd(a, b)*b;}
const ll INF = 1LL << 60;
const ld PI = acos(-1);
void solve(){
  int N;cin>>N;
  vl A(N);rep(i,N)cin>>A[i];
  sort(all(A));
  vl B(N);rep(i,N)cin>>B[i];
  sort(all(B));
  ll ansa = 0,ansb=0;
  do{
    do{
      ll a=0,b=0;
      rep(i,N){
        if(A[i]>B[i])a++;
        else b++;
      }
      if(a>b)ansa++;
      else ansb++;
    }while(next_permutation(all(B)));
  }while(next_permutation(all(A)));
  ll x = ansa+ansb;
  cout<<((long double)ansa/(long double)x)<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  int num_tc = 1;
  //cin >> num_tc;
  rep(tc,num_tc){
    //cout << "Case #" << tc+1 << ": " ;// << endl;
    solve();
  }
}
            
            
            
        