Lab Schedule
Time limit2sMemory limit512 MB
Pick days to experiment so no two chosen days are within two days of each other, maximizing the sum of visit probabilities.
- Level
Medium4 of 10
- Topics
- Dynamic programming, Greedy
- Solved
- No attempts yet
Problem
Your friend Susan works in a biology lab. The rules there are strict, and she wants her boss to see her running an experiment. A single day of experiments drains her, so after every day she spends experimenting she needs at least two days off to recover. If she runs an experiment on Monday, the earliest she can run the next one is Thursday of the same week.
From the visit history Susan knows the probabilities for days, where is the probability that her boss visits the lab on day . She can experiment on as many days as she likes as long as she rests in between. Choose the schedule that maximizes the sum of the probabilities on the days she experiments, and report that maximum.
Input
The first line contains the number of test cases . ()
Each test case takes two lines. The first line contains the number of recorded days . () The second line contains probabilities, the chance that her boss visits on each day from day to day , separated by single spaces. Each probability is a decimal number between and , inclusive.
Output
For each test case, print the maximum total probability on its own line. Round the exact total to one decimal place, rounding a half up, and always print that one decimal digit. No exact total in the test data lands on a rounding boundary.