結果

問題 No.133 カードゲーム
ユーザー Naco
提出日時 2019-10-12 00:02:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 570 bytes
コンパイル時間 1,513 ms
コンパイル使用メモリ 170,220 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 19:34:17
合計ジャッジ時間 2,558 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

int main(){
    int N; cin >> N;
    int a[N];
    int b[N];
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++) cin >> b[i];
    sort(a,a+N);
    sort(b,b+N);
    double ans=0;
    int cnt=0;
    do{
        int tmp=0;
        for(int i=0;i<N;i++){
            if(a[i]>b[i]) tmp++;
        }
        if(tmp>=N/2+1){
            ans++;
        }
    }while(next_permutation(a,a+N));
    cout << setprecision(5) << double(ans/dfs(N)) << endl;
}
0