FactoryEmulation
TCCC07 Finals · 2007-07-30 · by Andrew_Lazarev
Problem Statement
You are playing a factory simulator. The rules are pretty easy. Initially, at time 0, your factory's productivity is equal to 1. During each second, you can either increase productivity by one or produce productivity units of goods.
You will be given a
Constraints
- orders will contain between 1 and 15 elements, inclusive.
- Each element of orders will be in the form "time goods income" (quotes for clarity).
- Each time will represent an integer between 1 and 10^5, inclusive, with no leading zeroes.
- Each goods and income will represent an integer between 1 and 10^9, inclusive, with no leading zeroes.
{"1 1 1", "2 2 2"}
Returns: 2
We can satisfy only one order. The second order can be satisfied either by producing 1 unit of goods in both units of time or by increasing productivity to 2 in the first unit of time and producing 2 units of goods after that.
{"5 1 8", "7 15 3"}
Returns: 11
We can satisfy both orders using the following strategy: Increase productivity during seconds 0, 1 and 2. It will become equal to 4. Produce 4 units of goods during seconds 3 and 4, for a total of 8 units of goods. Satisfy the first order at second 5. 7 units of goods will remain. Produce 4 units of goods during seconds 5 and 6, for a total of 8 additional units of goods. Satisfy the second order at time 7.
{"5 1 8", "7 16 3"}
Returns: 8
It is impossible to satisfy both orders.
{"12 39 19", "18 50 13"}
Returns: 19
{"40 264 318", "88 1660 1120", "54 28 39", "64 348 134", "90 286 3000"}
Returns: 4159
Submissions are judged against all 115 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FactoryEmulation with a public method long long maxIncome(vector<string> orders) · 115 test cases · 2 s / 256 MB per case