Save the computer
Time limit1sMemory limit256 MB
Spend a fixed budget on spare parts to maximize the product of per-part Poisson survival probabilities.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Math
- Solved
- No attempts yet
Problem
A computer is built from several components. If any one of them fails, the whole computer stops. The semester budget arrives in one lump at the start of the semester, so you can spend it on spare components and swap a spare in the moment something breaks.
Failures follow a Poisson distribution. The probability that component fails exactly times during time units is
Only one semester is considered here, so is fixed at 1 and the formula reduces to
is the expected number of times component fails in one semester. Failures of different components are independent.
If you buy spares of component , the computer keeps running as long as component fails at most times during the semester. One spare of component costs , and the total money spent on spares cannot exceed the budget . The probability that the computer survives the whole semester is the product of the per component probabilities.
Decide how many spares of each component to buy within the budget so that this probability is as large as possible.
Input
The first line contains the number of test cases ().
Each test case consists of three lines. The first line contains the number of components that may fail, (), and the budget (), separated by a single space. The second line contains floating point numbers. The th number is (), the expected number of times component fails in one semester. The third line contains integers. The th number is (), the price of one spare of component .
Output
For each test case, print the maximum survival probability you can reach on a line of its own, rounded to 5 decimal places.