結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  trineutron | 
| 提出日時 | 2019-11-05 13:54:09 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 674 bytes | 
| コンパイル時間 | 1,817 ms | 
| コンパイル使用メモリ | 172,944 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-15 00:01:44 | 
| 合計ジャッジ時間 | 3,045 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a.at(i);
    for (int i = 0; i < n; i++) cin >> b.at(i);
    int match = 0, win = 0;
    sort(a.begin(), a.end());
    do {
        sort(b.begin(), b.end());
        do {
            int win_local = 0;
            for (int i = 0; i < n; i++) {
                if (a.at(i) > b.at(i)) win_local++;
            }
            if (win_local > n / 2) win++;
            match++;
        } while (next_permutation(b.begin(), b.end()));
    } while (next_permutation(a.begin(), a.end()));
    cout << 1.0 * win / match << endl;
}
            
            
            
        