Factory Batch Profit (Game Adaptation)
Updated
Problem statement
Game model. A factory produces batches of several product types under a fixed budget.
For this exercise, assume product type i costs costs[i] to produce one batch and earns revenues[i] when that batch is sold. You may produce any nonnegative integer number of batches of each type.
All production costs must be paid from the initial budget before any batch is sold. Sales cannot be reinvested in this run. Batches do not share machines or constrain one another. Return the maximum net profit: total sales revenue minus total production cost. You may leave capital unused or produce nothing. Keep the inputs unchanged.
Function
maxFactoryProfit(costs: int[], revenues: int[], budget: int) → intExamples
Example 1
costs = [2,3]revenues = [5,7]budget = 7return = 10Two batches of the first product and one of the second cost 7 and sell for 17, giving profit 10.
Example 2
costs = [5]revenues = [3]budget = 10return = 0Every batch loses money; producing nothing is best.
Example 3
costs = [4,6]revenues = [9,14]budget = 12return = 16Two batches of the second product earn 28 and cost 12, beating three batches of the first.
Constraints
1 <= costs.length == revenues.length <= 30.1 <= costs[i] <= 100;0 <= revenues[i] <= 1000.0 <= budget <= 2000.- The returned profit fits a signed 32-bit integer.
More Roblox Online Assessment questions
- Centered Block Placement QueriesOA · Seen Oct 2026
- Robot Navigation Around LasersOA · Seen Oct 2026
- Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
- Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
- Track Received Byte RangesOA · Seen Sep 2026
- Break a PalindromeOA · Seen Jun 2026
- Count Pairs Differing in One DigitOA · Seen Oct 2025
- Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
- Cat Route Budget Planning (Game Adaptation)OA · Seen Aug 2025
- Minimum Height Difference Between Distant PeaksOA · Seen Aug 2025
Similar questions at other companies
- 0/1 KnapsackConfluent · OAConfluent interview questions
- Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
- Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
- Maximum Subarray SumStraive · OA
- Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
- Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
- Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
- API Bandwidth AllocationArista Networks · OAArista Networks interview questions
- Maximum Points by Deleting ElementsIBM · OAIBM interview questions
- House RobberWalmart · OAWalmart interview questions