#P15878. [ICPC 2026 NAC] Draw Your Deck
[ICPC 2026 NAC] Draw Your Deck
Description
You are playing a single-player game with a deck of cards. The deck has cards, each with an integer between and written on it. You shuffle the deck and draw a card, which forms your starting hand. You then play the game by repeatedly choosing and discarding a card from your hand. Each time you do so, you draw as many cards from the top of the deck into your hand as the integer written on the card you just discarded. (If there are not enough cards left in the deck, you draw them all.) You win if you draw all of the cards from the deck and you lose if you run out of cards in your hand when there are still cards left in the deck. Given the contents of the deck, and assuming that all possible shuffles of the deck are equally likely and that you play optimally, what is the probability you win the game?
Input Format
The first line of input contains two space-separated integers and , where is the number of cards in the deck and is the largest integer written on any of the cards.
The second line contains space-separated integers , starting at : the number of cards in the deck with the integer written on them. It is guaranteed that and that the sum of all of the is .
Output Format
Print a real number: the probability that you win if you play optimally. Your answer will be accepted if it differs from the judge solution by an absolute error of at most .
4 2
2 0 2
0.3333333333333333
5 1
3 2
0.0
京公网安备 11011102002149号