結果

問題 No.173 カードゲーム(Medium)
ユーザー __math__math
提出日時 2015-03-27 00:16:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,893 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 99,916 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 10:30:42
合計ジャッジ時間 8,982 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 849 ms
4,376 KB
testcase_06 AC 635 ms
4,376 KB
testcase_07 AC 521 ms
4,380 KB
testcase_08 AC 518 ms
4,380 KB
testcase_09 AC 1,421 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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() % (n - i);
			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