結果

問題 No.133 カードゲーム
コンテスト
ユーザー 西海湖季
提出日時 2026-04-04 01:32:45
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 753 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,778 ms
コンパイル使用メモリ 337,588 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-04 01:33:14
合計ジャッジ時間 6,469 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=10000000;

int main(){  
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
   
    int N;
    cin>>N;
    vector<int> Acard(N);
    vector<int> Bcard(N);
    rep(i,N){
        cin>>Acard[i];
    }
    rep(i,N){
        cin>>Bcard[i];
    }
    double res=0;
    sort(Bcard.begin(),Bcard.end());
    do{
    int sum=0;
    rep(i,N){
        if(Acard[i]>Bcard[i]) sum++;
    }
    if(sum>N/2) res++;

    }while(next_permutation(Bcard.begin(),Bcard.end()));
  
    double all=1;
    for(int i=N;i>0;i--){
        all*=i;
    }

    cout<<res/all<<endl;

}   
0