結果

問題 No.173 カードゲーム(Medium)
ユーザー __math__math
提出日時 2015-03-27 00:25:02
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,903 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 99,692 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 10:31:51
合計ジャッジ時間 2,913 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <limits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)

// #pragma comment(linker,"/STACK:36777216")

template<class T> void chmax(T& l, const T r) { l = max(l, r); }
template<class T> void chmin(T& l, const T r) { l = min(l, r); }

void shu(int* a, int n, double p) {
	static vector<int> cur;
	cur.clear();
	FOR(i, n) cur.push_back(a[i]);
	FOR(i, n) {
		int x = rand();
		if (x <= p * double(RAND_MAX)) {
			a[i] = cur.back();
			cur.pop_back();
		} else {
			int idx = rand() % (sz(cur) - 1) + 1;
			a[i] = cur[idx];
			cur.erase(cur.begin() + idx);
		}
	}
}

int main() {
	int n;
	double pa, pb; cin >> n >> pa >> pb;
	int a[20], b[20];
	FOR(i, n) cin >> a[i];
	FOR(i, n) cin >> b[i];
	sort(a, a + n);
	sort(b, b + n);
	reverse(a, a + n);
	reverse(b, b + n);

	srand(time(NULL));
	const int X = ten(6);
	int ans = 0;
	int _a[20] = {}, _b[20] = {};
	FOR(_, X) {
		memcpy(_a, &a[0], sizeof(a));
		memcpy(_b, &b[0], sizeof(b));
		shu(_a, n, pa);
		shu(_b, n, pb);
		int da = 0;
		FOR(i, n) {
			int sm = _a[i] + _b[i];
			if (_a[i] > _b[i]) da += sm;
			else da -= sm;
		}
		if (da > 0) ans++;
	}

	printf("%.10lf\n",ans / double(X));
}
0