結果

問題 No.133 カードゲーム
ユーザー Tatsuhiko AraiTatsuhiko Arai
提出日時 2019-01-18 05:42:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 67,180 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 21:27:51
合計ジャッジ時間 1,733 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/**
 * yukicoder 133
 * カードゲーム
 *
 * next_permutation
 */
#include <iostream>
#include <algorithm>
using namespace std;

inline int factorial(int n) {
  int f{1};
  for (int i{2}; i <= n; ++i) f *= i;
  return f;
}

inline int solve1() {
  int N; scanf("%d", &N);
  int A[N]; for (int i{}; i < N; ++i) scanf("%d", &A[i]);
  int B[N]; for (int i{}; i < N; ++i) scanf("%d", &B[i]);

  int won{};
  do {
    int win{};
    for (int i{}; i < N; ++i) {
      if (A[i] > B[i]) ++win;
    }
    if (win > N / 2) ++won;
  } while (next_permutation(B, B+N));

  printf("%f\n", static_cast<double>(won) / factorial(N));
  return 0;
}

int main() {
  return solve1();
}
0