結果

問題 No.1151 チャレンジゲーム
ユーザー uzzyuzzy
提出日時 2020-08-08 00:44:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,616 bytes
コンパイル時間 2,382 ms
コンパイル使用メモリ 185,980 KB
実行使用メモリ 10,308 KB
最終ジャッジ日時 2023-10-25 07:27:49
合計ジャッジ時間 4,471 ms
ジャッジサーバーID
(参考情報)
judge11 / 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 1 ms
4,348 KB
testcase_05 AC 1 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 8 ms
8,516 KB
testcase_14 AC 8 ms
8,516 KB
testcase_15 AC 7 ms
8,516 KB
testcase_16 AC 8 ms
8,516 KB
testcase_17 AC 7 ms
8,516 KB
testcase_18 AC 8 ms
8,516 KB
testcase_19 AC 7 ms
8,516 KB
testcase_20 AC 8 ms
8,516 KB
testcase_21 AC 7 ms
8,516 KB
testcase_22 AC 7 ms
8,516 KB
testcase_23 AC 8 ms
8,516 KB
testcase_24 AC 8 ms
8,516 KB
testcase_25 AC 7 ms
8,516 KB
testcase_26 AC 7 ms
8,516 KB
testcase_27 AC 8 ms
8,516 KB
testcase_28 AC 17 ms
10,308 KB
testcase_29 AC 16 ms
10,308 KB
testcase_30 AC 18 ms
10,308 KB
testcase_31 AC 16 ms
10,308 KB
testcase_32 AC 18 ms
10,308 KB
testcase_33 AC 18 ms
10,308 KB
testcase_34 AC 17 ms
10,308 KB
testcase_35 AC 18 ms
10,308 KB
testcase_36 AC 18 ms
10,308 KB
testcase_37 AC 19 ms
10,308 KB
testcase_38 AC 18 ms
10,308 KB
testcase_39 AC 17 ms
10,308 KB
testcase_40 AC 19 ms
10,308 KB
testcase_41 AC 15 ms
10,308 KB
testcase_42 AC 19 ms
10,308 KB
testcase_43 AC 17 ms
10,308 KB
testcase_44 AC 15 ms
10,308 KB
testcase_45 AC 18 ms
10,308 KB
testcase_46 AC 19 ms
10,308 KB
testcase_47 AC 17 ms
10,308 KB
testcase_48 AC 7 ms
10,308 KB
testcase_49 AC 8 ms
10,308 KB
testcase_50 AC 16 ms
10,308 KB
testcase_51 AC 20 ms
10,308 KB
testcase_52 AC 19 ms
10,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int A[10];
double dp[1024][410][2];
double keisan(int i, int s, int t) {
	if (dp[i][s][t] >= 0) return dp[i][s][t];
	if (i == 0) {
		if (s > 200) dp[i][s][t] = 1;
		else dp[i][s][t] = 0;
		return dp[i][s][t];
	}

	if (t) {
		double ret = 1;
		rep(x, N) if (i >> x & 1) {
			double tmp = keisan(i - (1 << x), s - A[x], 0) / A[x] + keisan(i, s, 0) * (1 - 1.0 / A[x]);
			chmin(ret, tmp);
		}
		return dp[i][s][t] = ret;
	}

	double ret = 0;
	rep(x, N) if (i >> x & 1) {
		double ret2 = 1;
		rep(y, N) if (i >> y & 1) {
			double p1 = 1.0 / A[x];
			double p2 = 1.0 / A[y];

			double tmp1 = p1 / (p1 + (1 - p1) * p2) * keisan(i - (1 << x), s + A[x], 1);
			double tmp2 = (1 - p1) * p2 / (p1 + (1 - p1) * p2) * keisan(i - (1 << y), s - A[y], 0);
			chmin(ret2, tmp1 + tmp2);
		}
		chmax(ret, ret2);
	}
	return dp[i][s][t] = ret;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	rep(i, N) cin >> A[i];
	rep(i, 1 << N) rep(j, 401) rep(k, 2) dp[i][j][k] = -1;
	
	double kotae = keisan((1 << N) - 1, 200, 0);
	cout << setprecision(12) << kotae << endl;

	Would you please return 0;
}
0