#P9761. Maximizing Parts Production
Maximizing Parts Production
Maximizing Parts Production
There are two machines. The first machine requires \(a\) minutes to start up, and after that, it produces \(x\) parts per minute. The second machine requires \(b\) minutes to start up, and then produces \(y\) parts per minute. Note that the two machines cannot be in the startup process simultaneously.
You are given a total of \(k\) minutes. Determine the maximum number of parts that can be produced.
Note: The production phase (after startup) can run concurrently.
inputFormat
The input consists of a single line containing five space-separated integers:
- \(a\): the startup time (in minutes) for the first machine,
- \(x\): the number of parts produced per minute by the first machine after startup,
- \(b\): the startup time (in minutes) for the second machine,
- \(y\): the number of parts produced per minute by the second machine after startup,
- \(k\): total available time (in minutes).
outputFormat
Output a single integer representing the maximum number of parts that can be produced within \(k\) minutes.
sample
3 10 5 20 9
90