#P4978. Tomoo vs. CYJian Card Duel
Tomoo vs. CYJian Card Duel
Tomoo vs. CYJian Card Duel
In this duel, $\mathcal{tomoo}$ and $\mathcal{CYJian}$ are fighting using decks of cards. $\mathcal{tomoo}$ has $\mathcal{N}$ cards with RP values $\mathcal{A_i}$, and $\mathcal{CYJian}$ has $\mathcal{M}$ cards with RP values $\mathcal{B_i}$.
Both players will choose a contiguous segment of their cards. Denote the sum of the chosen segment for $\mathcal{tomoo}$ as:
$$S_A = \sum_{i=l}^{r} \mathcal{A_i}, \quad 1 \le l \le r \le \mathcal{N} $$and for $\mathcal{CYJian}$ as:
$$S_B = \sum_{j=p}^{q} \mathcal{B_j}, \quad 1 \le p \le q \le \mathcal{M} $$$\mathcal{tomoo}$ wins the duel if $S_A > S_B$. Assuming that both players choose their contiguous segments uniformly at random among all possible contiguous segments, calculate the probability that $\mathcal{tomoo}$ wins.
inputFormat
The first line contains two integers $\mathcal{N}$ and $\mathcal{M}$, the number of cards $\mathcal{tomoo}$ and $\mathcal{CYJian}$ have respectively.
The second line contains $\mathcal{N}$ integers $\mathcal{A_1}, \mathcal{A_2},\dots, \mathcal{A_N}$ representing the RP values of $\mathcal{tomoo}$'s cards.
The third line contains $\mathcal{M}$ integers $\mathcal{B_1}, \mathcal{B_2},\dots, \mathcal{B_M}$ representing the RP values of $\mathcal{CYJian}$'s cards.
outputFormat
Output a single line containing the probability that $\mathcal{tomoo}$ wins, formatted as a floating point number with 6 decimal places.
sample
1 1
5
3
1.000000
</p>