Archery Accuracy
Time limit7sMemory limit1024 MB
Given each archer's hit probability and the round thresholds, find the order of archers that maximizes the chance the final scoreboard is positive.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Bit manipulation, Probability
- Solved
- No attempts yet
Problem
You are managing an archery team for a competition. Each team member has their own fixed probability of hitting a target.
The tournament works in a series of rounds. Your team has the same number of members as there are rounds in the tournament. In each round, exactly one of your team members will participate. Each team member will participate in exactly one round. You, being the manager, get to decide in what order the team members will compete. You must submit the order to the judges before the first round starts.
The competition has a scoreboard, which shows the total number of hits minus misses. The scoreboard starts at zero at the beginning of the competition, and is cumulative. It does not get reset across rounds. A hit will increase the score by , while a miss will decrease it by . The scoreboard can go below zero.
The competition organizers have specified a list of strictly increasing positive thresholds, one per round. In each round, the chosen team member will repeatedly shoot at a target until the scoreboard has absolute value equal to the threshold. Remember that the scoreboard does not get reset across rounds.
Given that you know the thresholds as well as all of your team members' abilities, find the maximum possible probability that you will end the tournament with a positive number of hits.
Input
The first line of input contains a single integer (), which is both the number of team members on your team and the number of rounds of the tournament.
Each of the next lines contains a single real number (), the probability that the given team member hits a target. The probabilities have at most two digits after the decimal point.
Each of the next lines contains a single integer (), the threshold score for the given round. The values are strictly increasing.
Output
Output a single real number, the maximum probability that you end the tournament with a positive number of hits. The answer must be accurate to within an absolute or relative error of .