結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-05-30 19:19:59 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 5,000 ms | 
| コード長 | 1,103 bytes | 
| コンパイル時間 | 3,562 ms | 
| コンパイル使用メモリ | 197,672 KB | 
| 最終ジャッジ日時 | 2025-01-21 20:47:12 | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h> 
using namespace std;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t;
    vector <int> a, b;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        a.push_back(t);
    }
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        b.push_back(t);
    }
    double total = 0;
    double res = 0;
    sort(a.begin(), a.end());
    do
    {
        sort(b.begin(), b.end());
        do
        {
            int scoreA = 0;
            int scoreB = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] > b[i])
                {
                    scoreA++;
                }
                else
                {
                    scoreB++;
                }
            }
            if (scoreA > scoreB)
            {
                res++;
            }
            total++;
        } while (next_permutation(b.begin(), b.end()));
    } while (next_permutation(a.begin(), a.end()));
    cout << fixed;
    cout.precision(9);
    cout << (res / total) << '\n';
    return 0;
}
            
            
            
        