結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  hotpepsi | 
| 提出日時 | 2015-01-22 23:48:02 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 717 bytes | 
| コンパイル時間 | 656 ms | 
| コンパイル使用メモリ | 66,108 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-25 03:26:31 | 
| 合計ジャッジ時間 | 1,280 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
	cout.precision(16);
	string s;
	getline(cin, s);
	int N = atoi(s.c_str());
	int A[256] = {}, B[256] = {};
	string a, b;
	getline(cin, a);
	getline(cin, b);
	stringstream sa(a), sb(b);
	for (int i = 0; i < N; ++i) {
		sa >> A[i];
		sb >> B[i];
	}
	int t = 0, w = 0;
	sort(A, A + N);
	do {
		sort(B, B + N);
		do {
			int c = 0;
			for (int i = 0; i < N; ++i) {
				c += A[i] > B[i];
			}
			++t;
			if (c > N / 2) {
				++w;
			}
		} while (next_permutation(B, B + N));
	} while (next_permutation(A, A + N));
	double ans = (double)w / (double)t;
	cout << ans << endl;
	return 0;
}
            
            
            
        