結果

問題 No.133 カードゲーム
ユーザー chocopuuchocopuu
提出日時 2018-07-13 21:00:41
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 822 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 70,024 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 05:07:21
合計ジャッジ時間 1,521 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
typedef long long ll;
static const ll maxLL = (ll)1 << 62;

int main(){
    int n;
    cin>>n;
    vector<int> a,b;
    rep(i,0,n){
        int c;
        cin>>c;
        a.pb(c);
    }
    rep(i,0,n){
        int c;
        cin>>c;
        b.pb(c);
    }
    sort(a.begin(),a.end());
    int all=0;
    int win=0;
    do{
        int c=0;
        rep(i,0,n){
            if(a[i]>b[i]){
                c++;
            }
        }
        all++;
        if(c>n-c){
            win++;
        }
    }while(next_permutation(a.begin(),a.end()));
    cout<<1.*win/all<<endl;
    return 0;
}
0