結果

問題 No.133 カードゲーム
ユーザー Linasama
提出日時 2025-05-25 18:41:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 761 bytes
コンパイル時間 2,602 ms
コンパイル使用メモリ 197,884 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-25 18:41:54
合計ジャッジ時間 3,657 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int f(int n){
    if(n == 1) return 1;
    else return n * f(n - 1);
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int k = n / 2 + 1;
    int cnt = 0;
    int all = f(n) * f(n);
    do{
        do{
            int aw = 0;
            for(int i = 0; i < n; i++){
                if(a[i] > b[i]) aw++;
            }
            if(aw >= k) cnt++;

        }while(next_permutation(a.begin(), a.end()));
    }while(next_permutation(b.begin(), b.end()));

    long double ans = (long double)cnt / all;
    cout << ans << endl;
    return 0; 
}

0