#P13800. [SWERC 2023] Throwing dice

[SWERC 2023] Throwing dice

题目描述

:::align{center}

:::

Alice and Bob are discussing penalty shoot-outs and their randomness: "We might as well be throwing dice to determine the winner!", Alice said. And so they started simulating penalty shoot-outs by each throwing dice, summing the points indicated on their dice, and comparing these sums. The player with the largest sum wins; in case both sums are equal, there is a tie.

But even in such situations, some player might have an edge over their opponent, depending on which dice they throw. Thus, just by looking at the dice they are about to throw, Alice and Bob want to determine who has the better edge.

Alice has MM fair dice, with A1,A2,,AMA_1, A_2, \dots, A_M sides. For all integers kk and ll such that 1kM1 \leq k \leq M and 1lAk1 \leq l \leq A_k, the kthk^\text{th} die of Alice has a probability 1/Ak1/A_k of showing its face numbered ll. Then, Alice's score is the sum of the numbers displayed by her MM dice. Similarly, Bob has NN fair dice, with B1,B2,,BNB_1, B_2, \dots, B_N sides.

Given these dice, Alice has a probability PA\mathbb{P}_A of having a strictly larger score than Bob, and Bob has a probability PB\mathbb{P}_B of having a strictly larger score than Alice. Which probability is the largest one?

输入格式

The input consists of three lines, each one containing space-separated integers. The first line contains the numbers MM and NN. The second line contains the numbers A1,A2,,AMA_1, A_2, \dots, A_M. The third line contains the numbers B1,B2,,BNB_1, B_2, \dots, B_N.

Limits

  • 1M100 0001 \leq M \leq 100~000;
  • 1N100 0001 \leq N \leq 100~000;
  • 4Ak1 000 000 0004 \leq A_k \leq 1~000~000~000 for all kMk \leq M;
  • 4Bk1 000 000 0004 \leq B_k \leq 1~000~000~000 for all kNk \leq N;

输出格式

The output should contain a single line, consisting of a single uppercase word: ALICE\texttt{ALICE} if PA>PB\mathbb{P}_A > \mathbb{P}_B, TIED\texttt{TIED} if PA=PB\mathbb{P}_A = \mathbb{P}_B, and BOB\texttt{BOB} if PA<PB\mathbb{P}_A < \mathbb{P}_B.

8 1
4 4 4 4 4 4 4 4
6
ALICE
2 2
6 4
4 6
TIED

提示

Sample Explanation 1

Since Alice has 8 dice, her score is always 8 or more; Bob's score is always 6 or less. Hence, Alice has a probability PA=100%\mathbb{P}_A = 100\% of beating Bob, and he has a probability PB=0%\mathbb{P}_B = 0\% of beating her. Consequently, PA>PB\mathbb{P}_A > \mathbb{P}_B.

Sample Explanation 2

Alice has a probability PA=125/288\mathbb{P}_A = 125/288 of beating Bob; he also has a probability PB=125/288\mathbb{P}_B = 125/288 of beating her.