This question was asked as a programming puzzle recently, but I want to know the math behind how to solve it.
The kingdom of Byteland contains $N$ cities numbered $1$ through $N$. For each city $i$, the king assigns some money to that city for its annual maintenance. The amount assigned is chosen randomly between $a_i$ (the minimum amount needed by that city), and $b_i$ (the maximum amount that can be assigned to that city). Note that the amount assigned to a city need not be an integer. The total tax collected this year is $C$.
What is the probability that the kingdom will issue a loss this year? In other words, what is the probability that the total amount assigned to all cities exceeds the total tax collected?
And a sample answer was
$N = 1, ~C = 3, ~a_1 = 1, ~b_1 = 10, ~\text{Answer} = 0.77778.$
And where can I find good references for studying some advanced topics of probability theory. I am quite aware of the basics but while applying to problems like above I get lost.