Production System Management
InterviewTime limit1sMemory limit512 MB
Given N jobs whose success probability rises with each extra machine, buy machines within budget B to maximize the product of all success probabilities.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Implementation
- Solved
- No attempts yet
Problem
In the land of the winter forest, a production system is made up of kinds of jobs. The goal is for every job in this system to work correctly.
Job is carried out by running machine . When there is one machine , the probability that job works correctly is . Each additional machine purchased raises that probability by . However, no matter how many machines are bought, the probability that job works correctly cannot exceed .
For example, suppose there are jobs 1 and 2 with , , , and . When there is one machine each for machines 1 and 2, the probability that every job works correctly is . However, if you buy 2 more of machine 1 and 1 more of machine 2, giving 3 and 2 machines in total, improves to . If machine costs , how can be maximized with total cost at most ?
Initially, there is one machine of each kind.
Input
The first line contains an integer (), the number of job types, and an integer (), the budget.
The next lines each contain integers , , and separated by spaces. (, )
Output
On the first line, print the maximum possible value of multiplied by , using a total cost of at most . This value is always an integer.
On the second line, print the number of additional machines to buy for each machine in order, separated by spaces.
If there are several ways, print any of them.