結果

問題 No.133 カードゲーム
コンテスト
ユーザー a01sa01to
提出日時 2025-12-20 01:20:48
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 706 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,035 ms
コンパイル使用メモリ 286,312 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-20 01:20:53
合計ジャッジ時間 4,527 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  ranges::sort(a), ranges::sort(b);
  int ans = 0, cnt = 0;
  do {
    do {
      ++cnt;
      int pts = 0;
      rep(i, n) {
        if (a[i] > b[i]) ++pts;
        if (a[i] < b[i]) --pts;
      }
      ans += pts > 0;
    } while (next_permutation(b.begin(), b.end()));
  } while (next_permutation(a.begin(), a.end()));
  cout << fixed << setprecision(15) << (double) ans / cnt << '\n';
  return 0;
}
0