#P4624. Mineral Collection Optimization
Mineral Collection Optimization
Mineral Collection Optimization
This problem is set on a distant planet where there exist two different minerals. One mineral is called "ice mineral", a blue high‐energy mineral similar to a frozen form of \( H_{2}O \). The other is called "gas mineral", an anomalous form of tetrachloride. Through refining these two minerals, humanity gains the energy necessary for survival.
The only machine able to extract these minerals is the \(\text{SCV}\). An \(\text{SCV}\) takes \(t_{1}\) time to extract an ice mineral batch and \(t_{2}\) time to extract a gas mineral batch. Each extraction returns 8 units of the chosen mineral. Note that in one extraction, an \(\text{SCV}\) can only extract one kind of mineral.
The base can also produce additional \(\text{SCV}\)'s. Producing one \(\text{SCV}\) costs 50 units of ice mineral and takes \(t_{3}\) time. However, the base has a limited production capability so that it can produce only one \(\text{SCV}\) at a time.
Initially, you have 50 units of ice mineral and 4 \(\text{SCV}\)'s. The goal is to collect at least \(p_{1}\) units of ice mineral and \(p_{2}\) units of gas mineral. Remember that if you produce additional \(\text{SCV}\)'s, you have to pay an extra 50 units of ice mineral per produced unit (and that cost counts toward the ice mineral requirement). Your task is to compute the minimum time needed to achieve the resource targets.
Additional details:
- Each extraction yields exactly 8 units.
- An \(\text{SCV}\) can never switch between mineral types during an extraction cycle. However, an \(\text{SCV}\)'s overall working time can be divided between ice and gas extractions.
- The production timeline for new SCVs is as follows: if you decide to produce \(k\) new \(\text{SCV}\)'s, they will finish production at times \(t_{3}, 2t_{3}, \dots, kt_{3}\) respectively. These new SCVs can then start collecting minerals after their production is complete.
- The ice mineral you have initially (50 units) can be used both toward the target \(p_{1}\) and for paying the production cost (50 units per new SCV produced). Therefore, if you produce \(k\) new SCVs, you must eventually have collected at least \(p_{1} + 50k\) units of ice mineral.
- All \(\text{SCV}\)'s can work concurrently, while the base can produce only one \(\text{SCV}\) at a time.
- Time units are assumed to be integer values.
Input and Output:
The input consists of five space‐separated integers: \(t_{1}\), \(t_{2}\), \(t_{3}\), \(p_{1}\), and \(p_{2}\). The output should be the minimum time required.
Hint: It might be optimal to produce extra \(\text{SCV}\)'s; however, note that each extra \(\text{SCV}\) costs both 50 ice units and \(t_{3}\) time.
inputFormat
The input consists of 5 space‐separated integers:
t1
: time for an \(\text{SCV}\) to extract ice mineral once.t2
: time for an \(\text{SCV}\) to extract gas mineral once.t3
: time required by the base to produce one \(\text{SCV}\).p1
: required units of ice mineral.p2
: required units of gas mineral.
outputFormat
Output a single integer representing the minimum time needed to reach at least p1
units of ice mineral and p2
units of gas mineral (remembering that if additional \(\text{SCV}\)'s are produced, an extra 50 ice units per produced \(\text{SCV}\) must also be collected).
sample
1 2 3 100 40
9