結果

問題 No.133 カードゲーム
ユーザー NozeNoze
提出日時 2019-08-17 22:38:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,245 bytes
コンパイル時間 891 ms
コンパイル使用メモリ 96,472 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 23:48:15
合計ジャッジ時間 1,964 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  vector<int> ai(N), bi(N);
  iota(ai.begin(), ai.end(), 0);
  iota(bi.begin(), bi.end(), 0);
  int res = 0;
  do {
    do {
      vector<int> x(N);
      rep(i, N){
        x[ai[i]] += A[i];
        x[bi[i]] -= B[i];
      }
      int win = 0;
      rep(i, N) {
        if(x[i] > 0)
          win++;
      }
      if(win > N/2.0)
        res++;
    } while(next_permutation(bi.begin(), bi.end()));
  } while(next_permutation(ai.begin(), ai.end()));
  int fac = 1;
  for(int i=2; i<=N; i++)
    fac = fac*i;
  int all = fac*fac;
  cout << (double)res/all << endl;
  return 0;
}
0