Expected value of one die. A die with sides shows each of the faces 1, 2, ..., s with probability , so its expected value is the arithmetic mean of these numbers:
The expected value of a sum equals the sum of the expected values, so for Alice's score and Bob's score
The scores are distributed symmetrically about their expected values. On a single die, the values and , and s - 1, and so on, occur with equal probability, so the die is symmetric about (1 + s) / 2. A sum of symmetric random variables is also symmetric about its expected value.
Alice has the advantage if E[A] > E[B], and Bob has it if E[A] < E[B]. Therefore,
To solve the problem, it is enough to compare the sums SA = \sum a_k + m and SB = \sum b_k + n.
Example
Alice has eight dice with sides, and Bob has one die with sides. Then SA = 8 \cdot 4 + 8 = 40 and SB = 6 + 1 = 7, so SA > SB, and the answer is ALICE.
Let us verify this directly. The smallest sum Alice can get is 8 \cdot 1 = 8, while Bob's largest sum is . Therefore Alice wins for every outcome of the rolls: p_a = 1, p_b = 0.
Consider the second test. Alice has dice with and sides, and Bob has dice with and sides. Then SA = 6 + 4 + 2 = 12 and SB = 4 + 6 + 2 = 12, so SA = SB, and the answer is TIED.
This is clear even without any computation: Alice and Bob have the same sets of dice, only listed in a different order. Therefore their scores have the same distribution, and p_a = p_b.
Algorithm implementation
Read the input data. Accumulate the sum \sum a_k + m in the variable , and the sum \sum b_k + n in the variable .
scanf("%d %d", &m, &n);
sA = m; sB = n;
for (i = 0; i < m; i++)
{
scanf("%d", &x);
sA += x;
}
for (i = 0; i < n; i++)
{
scanf("%d", &x);
sB += x;
}Compare the sums and print the answer.
if (sA > sB)
puts("ALICE");
else if (sA < sB)
puts("BOB");
else
puts("TIED");