結果

問題 No.133 カードゲーム
ユーザー DAISUKE
提出日時 2021-02-22 11:33:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,010 bytes
コンパイル時間 2,223 ms
コンパイル使用メモリ 196,964 KB
最終ジャッジ日時 2025-01-19 03:24:35
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const ll INF_L = 1LL << 60;
const int INF_I = 1 << 30;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

int main()
{
    int n;
    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));

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

    printf("%5f\n", 1. * win / cnt);
    return 0;
}
0