結果

問題 No.133 カードゲーム
ユーザー Ruo-pro
提出日時 2021-08-30 15:28:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 700 bytes
コンパイル時間 949 ms
コンパイル使用メモリ 81,460 KB
最終ジャッジ日時 2025-01-24 04:05:17
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>

#define INF 1<<29
using namespace std;


using Graph = vector<vector<int>>;


using ll = long long;

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (auto& x : a ) {
		cin >> x;
	}
	for (auto& x : b) {
		cin >> x;
	}
	int cnt = 0;
	int ans = 0;
	int res = 0;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	do {
		do {
			res++;
			cnt = 0;
			for (int i = 0; i < n; i++) {
				if (a[i] > b[i])cnt++;
			}
			if (cnt > (n / 2))ans++;

		} while (next_permutation(b.begin(), b.end()));
	} while (next_permutation(a.begin(), a.end()));
	
	
	cout << (double)ans / res << endl;
	return 0;
}
0