結果

問題 No.133 カードゲーム
ユーザー tadanoningen
提出日時 2021-01-21 13:16:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 601 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 76,428 KB
最終ジャッジ日時 2025-01-18 03:04:36
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 5 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),ind(n);
    for(auto &x : a) cin >> x;
    for(auto &x : b) cin >> x;
    for(int i=0;i < n;i++) ind[i] = i+1;
    int all = 0,win = 0;
    
    do{
        int aa = 0;
        for(int i=0;i < n;i++){
            if(a[i] > b[ind[i]]) aa++;
            else aa--;
        }
        all++;
        if(aa > 0) win++;
    }while(next_permutation(ind.begin(),ind.end()));
    
    double ans = (double)win/(double)all;
    
    cout << ans << endl;
    return 0;
}
0