結果

問題 No.133 カードゲーム
ユーザー そゆそゆ
提出日時 2024-02-27 12:08:26
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 804 bytes
コンパイル時間 2,367 ms
コンパイル使用メモリ 159,684 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-27 12:08:30
合計ジャッジ時間 3,723 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) (v).begin(), (v).end()
using ll = long long;

int upstairs(int x) {
    if (x == 0) return 1;
    else return x * upstairs(x - 1);
}

int main() {
    int n, cnt = 0;
    cin >> n;
    vector<int> a(n), b(n);

    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    sort(all(a));
    sort(all(b));

    do {
        do {
            int acnt = 0, bcnt = 0;
            rep(i, n) {
                if(a[i] > b[i]) ++acnt;
                else if (a[i] < b[i]) ++bcnt;
            }
            if (acnt > bcnt) ++cnt;
        } while(next_permutation(all(b)));
    } while(next_permutation(all(a)));

    double ans;
    ans = cnt / pow(upstairs(n), 2);

    cout << ans << endl;

    return 0;
}
0