結果

問題 No.133 カードゲーム
ユーザー shakirashakira
提出日時 2020-11-21 02:55:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 707 bytes
コンパイル時間 1,983 ms
コンパイル使用メモリ 203,280 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 20:32:38
合計ジャッジ時間 3,076 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void potato() {
  int n;
  cin >> n;
  vector<double> a(n), b(n);
  for(auto& x : a) cin >> x;
  for(auto& x : b) cin >> x;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  double wins = 0, rounds = 0;
  do {
    do {
      int aw = 0, bw = 0;
      for(int i = 0; i < n; i++) {
        if(a[i] > b[i]) aw++;
        else bw++;
      }
      if(aw > bw) wins++;
      rounds++;
    } while(next_permutation(b.begin(), b.end()));
  } while(next_permutation(a.begin(), a.end()));

  double ans = wins / rounds;
  printf("%.6lf\n", ans);
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt=1;
  while(tt--) potato();
  return 0;
}
0