Problem P
Closing the Borders
After an epidemic hit most of Europe, countries have started announcing closures of their borders for travel. This is a problem for you, since you are currently on vacation in France, far away from your home in Sweden. You hope to get home before enough borders close so that you can no longer travel.
Through deep political analysis, you have determined that
the closure of a given country’s borders can be modelled in the
following way. At some day
You are currently in country
If you pick an optimal sequence of flights, what is the probability that it will take you home?
Input
The first line of the input contains two integers
The next
The final
Output
Output a single decimal number – the highest probability that you will get home, if you pick an optimal sequences of flights.
Your answer will be considered correct if you have an
absolute error of at most
Sample Input 1 | Sample Output 1 |
---|---|
3 2 1 3 1 3 1 3 0 1 1 2 |
0.25 |