結果

問題 No.133 カードゲーム
ユーザー nemakura3nemakura3
提出日時 2019-09-11 21:37:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 889 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 166,576 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-15 13:57:40
合計ジャッジ時間 2,498 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define rep(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for (int (i) = (n); (i) >= 0; --(i))
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1LL << 60;
const ll MOD = 1e9 + 7;

int N, A[4], B[4];

int main() {
    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    sort(A, A+N);
    sort(B, B+N);
    int awin = 0;
    int ap = 0;
    do {
        do {
            ++ap;
            int rawin = 0;
            rep(i,N) {
                if (A[i] > B[i]) ++rawin;
            }
            if (2*rawin > N) ++awin;
        } while (next_permutation(B, B+N));
    } while (next_permutation(A, A+N));
    double p = (double)awin / (double)ap;
    cout << fixed << setprecision(10) << p << "\n";
    return 0;
}
0