結果

問題 No.133 カードゲーム
ユーザー hackthionhackthion
提出日時 2020-01-24 12:58:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,137 bytes
コンパイル時間 1,872 ms
コンパイル使用メモリ 170,424 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 02:28:19
合計ジャッジ時間 3,422 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef pair<int, int> pint;
typedef vector<pint> vpint;

const int INF = 1e9;
const int MOD = 1e9+7;

vi A;
vi B;

int main(void)
{
  int N;
  cin >> N;
  A.resize(N);
  B.resize(N);
  forn (i, N) cin >> A[i];
  forn (i, N) cin >> B[i];

  sort(all(A));
  sort(all(B));

  ld ans;
  int cnt = 0, sum = 0;
  do {
    do {
      int scoreA = 0, scoreB = 0;
      forn (i, N) {
        if (A[i] > B[i]) ++scoreA;
        else ++scoreB;
      }
      if (scoreA > scoreB) ++cnt;
      ++sum;
    } while (next_permutation(all(B)));
  } while (next_permutation(all(A)));
  ans = (double)cnt / sum;
  cout << ans << endl;
}
0