結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-03-20 13:53:35 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 952 bytes | 
| コンパイル時間 | 1,889 ms | 
| コンパイル使用メモリ | 197,116 KB | 
| 最終ジャッジ日時 | 2025-02-11 15:36:39 | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#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;
  }
            
            
            
        