We have acquired a state-of-the-art ore processing facility, supposedly "to evaluate whether gzip can produce diamonds". The facility sequentially processes ore through $$$n$$$ stages, from a crude stage $$$1$$$, to the final stage $$$n$$$.
Each stage of refinement can consist of several machines. Each machine converts material $$$i$$$ into material $$$i+1$$$, but their efficiency varies, and only one is available at a time. Machine specifications detail how many units of an input material they consume and how many units of an output material they produce.
Storage being expensive, all input and output materials are stored in the same shared warehouse with maximum capacity $$$k$$$. Excess material can be sent away from the warehouse for disposal at any time.
Each stage must occur in-order; once any stage of processing is completed, it cannot be revisited.
As the new operations manager your task is to determine the maximum quantity of material $$$n$$$ that can be produced, given your initial stockpile of raw material $$$1$$$ and limited warehouse capacity $$$k$$$.
Output an integer, the maximum final quantity of material $$$n$$$.
3 55 51 5 41 3 21 2 12 1 12 3 4
5
4 411 251 2 31 1 12 1 43 3 4
25
2 24 101 3 51 2 3
6
2 14 71 2 4
7
2 17 71 3 5
5
| Название |
|---|


