SRM 740, D1, 250-Pointer (RainForecast)

James S. Plank

Sat Oct 27 12:44:22 EDT 2018
This problem is less about programming, and more about calculating probabilities. First, convert all of those integer percentages into doubles that are actual probabilities.

Next, calculate the probability that Ilko's model gets it correct. Call that C0. After calculating that, calculate the probability that Ilko's model gets it incorrect. Call that I0.

Now, consider each person in the delivery chain. Call that person i (zero indexed). For each of these people, you can calculate:

At the end of this process, you can simply return the greater of Cn and In, where n is the size of deliverProbs.

Working through the examples

Here are the Ci and Ci for all of the examples, followed by the return values:
UNIX> a.out 0
 i    C_i    I_i
-- ------ ------
 0 0.9300 0.0700
0.93
UNIX> a.out 1
 i    C_i    I_i
-- ------ ------
 0 0.9300 0.0700
 1 0.5000 0.5000
0.5
UNIX> a.out 2
 i    C_i    I_i
-- ------ ------
 0 1.0000 0.0000
 1 0.9000 0.1000
 2 0.8200 0.1800
0.82
UNIX> a.out 3
 i    C_i    I_i
-- ------ ------
 0 0.8900 0.1100
 1 0.2114 0.7886
 2 0.2576 0.7424
 3 0.7085 0.2915
0.708485
UNIX> a.out 4
 i    C_i    I_i
-- ------ ------
 0 0.5000 0.5000
 1 0.5000 0.5000
 2 0.5000 0.5000
 3 0.5000 0.5000
 4 0.5000 0.5000
 5 0.5000 0.5000
 6 0.5000 0.5000
0.5
UNIX>