#include <iostream>
#include <cmath>

const int STEPS = 200;

double signdiff(double magnitude, double sign) {
	if(fabs(sign) < 1e-5) { return 0; }
	if(sign > 0) { return magnitude; }
	return -magnitude;
}

double game_value(double L_1, double C_1, double L_2, double C_2) {
	double R_1 = 1-L_1-C_1;
	double R_2 = 1-L_2-C_2;

	// Same lottery returns value 0
	if (L_1 == L_2 && C_1 == C_2 && R_1 == R_2) { return 0; }
	// Anything that's out of bounds returns 1000 points for the other
	// player.
	if (L_1 < 0 || C_1 < 0 || R_1 < 0) { return -1000; }
	if (L_2 < 0 || C_2 < 0 || R_2 < 0) { return 1000; }

	double g_1, g_2, g_3;

	// Does the 40: L>C>R, p = 0.1 bloc prefer one of the lotteries?
	// If so, that's 40 points to the player playing that lottery.
	g_1 = signdiff(40, L_1 + 0.1 * C_1 - (L_2 + 0.1 * C_2));

	// Does the 30: R>C>L, p = 0.1 bloc prefer one of the lotteries?
	g_2 = signdiff(30, R_1 + 0.1 * C_1 - (R_2 + 0.1 * C_2));

	// Does the 20: C>R>L, p = 0.5 bloc prefer one of the lotteries?
	g_3 = signdiff(20, C_1 + 0.5 * R_1 - (C_2 + 0.5 * R_2));

	// Sum of preference scores.
	return g_1 + g_2 + g_3;
}

double player_two_second(double L_1, double C_1) {

	double score = 1e10, L_2, C_2;

	for (int i = 0; i <= STEPS; ++i) {
		L_2 = i/double(STEPS);
		for (int j = 0; j <= STEPS; ++j) {
			C_2 = j/double(STEPS);

			score = std::min(score, game_value(L_1, C_1, L_2, C_2));
		}
	}

	return score;
}

double player_one_first() {

	double score = -1e10, L_1, C_1;

	for (int i = 0; i <= STEPS; ++i) {
		L_1 = i/double(STEPS);
		std::cout << "Progress: " << L_1 << "\t" << score << std::endl;
		for (int j = 0; j <= STEPS; ++j) {
			C_1 = j/double(STEPS);

			score = std::max(score, player_two_second(L_1, C_1));
		}
	}

	return score;
}

// If the printed value is less than zero, that means that no matter what
// the maximizing player chooses, the minimizing player can choose a lottery
// that beats it. This would not be possible if there's a CW among the
// lotteries.
int main() {
	std::cout << player_one_first() << std::endl;
	return 0;
}
