結果

問題 No.133 カードゲーム
ユーザー fumiphysfumiphys
提出日時 2018-06-24 18:11:13
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 630 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 63,576 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-30 22:32:14
合計ジャッジ時間 1,374 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	int *a = new int[n];
	int *b = new int[n];
	for(int i = 0; i < n; i++){
			cin >> a[i];
	}
	for(int i = 0; i < n; i++){
			cin >> b[i];
	}
	vector<int> vec(n);
	iota(vec.begin(), vec.end(), 1);
	int all = 0;
	int win = 0;
	do{
			int count = 0;
			for(int i = 0; i < n; i++){
					if(a[i] > b[vec[i] - 1])count++;
			}
			if(count > n - count)win++;
			all++;
	}while(next_permutation(vec.begin(), vec.end()));
	cout << (double)win / (double)all << endl;
	return 0;
}
0