結果

問題 No.133 カードゲーム
ユーザー shimarutshimarut
提出日時 2019-06-02 20:16:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 748 bytes
コンパイル時間 1,006 ms
コンパイル使用メモリ 85,184 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 23:06:58
合計ジャッジ時間 2,085 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> a(n), b(n), perm(n);
	rep(i, 0, n - 1)
	{
		cin >> a[i];
		perm[i] = i;
	}
	rep(i, 0, n - 1)cin >> b[i];

	double cntN = 0;
	double allN = 0;
	do
	{
		int tempA = 0;
		int tempB = 0;
		rep(i, 0, n - 1)
		{
			if (a[i] > b[perm[i]])++tempA;
			if (a[i] < b[perm[i]])++tempB;
		}
		if (tempA > tempB)++cntN;
		++allN;
	} while (next_permutation(all(perm)));

	cout << cntN / allN << endl;
}
0