結果

問題 No.133 カードゲーム
ユーザー upperkyuuriupperkyuuri
提出日時 2018-09-29 12:27:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,119 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 67,160 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 12:49:54
合計ジャッジ時間 1,921 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<vector<int>> v = vector<vector<int>>(2, vector<int>(n, 0));
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < n; ++j) {
            int num;
            cin >> num;
            v[i][j] = num;
        }
    }
    
    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());
    
    int win = 0;
    int sum = 0;
    
    do {
        do {
            int win_a = 0;
            int win_b = 0;
            
            for (int i = 0; i < n; ++i) {
                if (v[0][i] > v[1][i]) {
                    win_a++;
                }
                if (v[0][i] < v[1][i]) {
                    win_b++;
                }
            }
            
            if (win_a > win_b) {
                win++;
            }
            
            sum++;
            
        } while (next_permutation(v[1].begin(), v[1].end()));
    } while (next_permutation(v[0].begin(), v[0].end()));

    cout << static_cast<double>(win) / sum << "\n";
    
    return 0;
}
0