Given n tables and random hourly group sizes from 1 to g, find the expected number of seated people after t hours, where each group takes the smallest table that fits.
Medium7Dynamic programmingProbabilitySimulationNo attempts yetTime limit2sMemory limit512 MBRobin found a place to live in the Swiss Alps and thought that happiness would follow. Every morning he woke up feeling that something was missing. Maybe the problem is that nobody around here cooks English food. Robin saw a business opportunity in that gap, and a way to solve his own problem at the same time, so he teamed up with the English chef Jim and opened a restaurant nearby. He has no doubts about Jim in the kitchen. He is much less sure that an English restaurant in the Swiss Alps is a good idea.
Robin is a local, so he knows how the customers behave. On the stroke of every hour exactly one group arrives. Its size is uniformly random between 1 and g people, inclusive, and is independent of every other group. The group sits down at the completely unoccupied table of smallest capacity among those that can seat the whole group. If no such table exists, the group leaves, deeply disappointed. A group that sits down never leaves before closing time, because Jim has no trouble keeping the guests entertained.
For example, suppose the restaurant has 3 tables of capacities 5, 8 and 9, and that groups of sizes 5, 10 and 3 arrive in that order. The first group takes the table of capacity 5, the second group leaves, and the third group takes the table of capacity 8. In the end 8 people are in the restaurant.
Robin plans to keep the restaurant open for t hours. In the restaurant business the number that matters most is the expected number of people in the restaurant at closing time. Compute it.
The first line contains three integers n, g and t (1≤n≤100, 1≤g≤200, 1≤t≤100): the number of tables, the largest possible group size, and the number of hours the restaurant stays open.
The second line contains n integers c1,…,cn (1≤ci≤200), the capacities of the tables.
Print the expected number of people in the restaurant at closing time, with exactly six digits after the decimal point.