lines assembly lines that all build the same product from parts of kinds different kinds. Their recipes differ, though: line i needs recipes[i][j] parts of kind j for one product.
The warehouse holds stock[j] parts of kind j. Missing parts can be bought: one part of kind j costs prices[j] coins, and you may spend at most budget coins in total.
All products must be built on the same line, which you choose. Return the largest number of products you can build.kinds=2, lines=2, budget=12, recipes=[[2, 1], [1, 3]], stock=[4, 0], prices=[3, 2] → 3
On line 0, three batches need 6 and 3 parts: buy 2 parts of kind 0 and 3 of kind 1 for 2·3 + 3·2 = 12. Four batches would cost 4·3 + 4·2 = 20. Line 1 manages only 2 batches (6 parts of kind 1 for 12 coins). The answer is 3.
kinds=1, lines=1, budget=0, recipes=[[5]], stock=[12], prices=[7] → 2
There is no money, and the stock covers 12 // 5 = 2 batches.
kinds, lines ≤ 100budget ≤ 10⁸lines, len(recipes[i]) = kindsrecipes[i][j] ≤ 100kindsstock[j] ≤ 10⁸prices[j] ≤ 100kinds=2, lines=2, budget=12, recipes=[[2, 1], [1, 3]], stock=[4, 0], prices=[3, 2]
3
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.