結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-01-12 17:25:42 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 925 bytes | 
| コンパイル時間 | 1,618 ms | 
| コンパイル使用メモリ | 170,724 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-23 11:12:39 | 
| 合計ジャッジ時間 | 2,624 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T &a, T b) { return ((a>b) ? (a = b, true) : (false));}
#define rep(i,s,n) for(long long i=s;i<(long long)(n);i++)
const long long inf = 1LL<<60;
typedef long long ll;
int main()
{
    int n; cin >> n;
    vector<int> a(n),b(n),order_a(n),order_b(n);
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    rep(i,0,n){
        order_a[i] = i;
        order_b[i] = i;
    }
    double win=0,lose=0;
    do{
        do{
            int cnt = 0;
            rep(i,0,n) cnt += (a[order_a[i]]>b[order_b[i]]);
            if(cnt>n/2) win++;
            else lose++;
        }while(next_permutation(order_b.begin(),order_b.end()));
    }while(next_permutation(order_a.begin(),order_a.end()));
    cout << setprecision(20) << win/(win+lose) << endl;
}
            
            
            
        