結果

問題 No.133 カードゲーム
ユーザー ri kanari kana
提出日時 2023-03-20 13:53:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 952 bytes
コンパイル時間 4,812 ms
コンパイル使用メモリ 206,828 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 18:04:48
合計ジャッジ時間 3,213 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 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 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30 ;
const ll INFLL = 1LL<<60;
const int MOD = 998244353;
#define rep(i,l,n) for(int i=l;i<n;i++)
#define per(i,l,r) for(int i=r;i>=l;i--)
#define test ifs("1test_inputs.txt")//ifstream test;
//=====================================================================================================================================================================
int main(){
  int N; cin >> N;
  vector<int> a(N), b(N);
  rep(i,0,N) cin >> a[i];
  rep(i,0,N) cin >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  int cnt_win = 0;
  int cnt_all = 0;
  do {
    do {
      int cnt = 0;
      rep(i,0,N){
        if(a[i] > b[i]) cnt++;
      }
      if(cnt > N/2) cnt_win++;
      cnt_all++;

    } while (next_permutation(b.begin(), b.end()));
  } while (next_permutation(a.begin(), a.end()));

  cout << cnt_win/(double)cnt_all << endl;
  return 0;
  }
0