Maximize Number of Produced Cars
Learn this problemProblem statement
A car manufacturer has data about the production processes of N different cars (numbered from 0 to N-1) and wants to maximize the number of cars produced in the upcoming month. The manufacturing information is described by an array H, where H[K] denotes the number of hours required to produce the K-th car.
There are two assembly lines in the factory, the first of which works for X, and the second Y, hours in a month. Every car can be constructed using either one of these lines. Only one car at a time can be produced on each assembly line and it is not possible to switch lines after starting the car's production.
What is the maximum number of different cars that can be produced in the upcoming month?
Function
maximizeNumberOfProducedCars(H: int[], X: int, Y: int) → intWrite a function:
def solution(H, X, Y)
that, given an array H of N integers and two integers X and Y, returns the maximum number of different cars that can be produced in the upcoming month by assigning cars to assembly lines in an optimal way.
Examples
Example 1
H = [1, 1, 3]X = 1Y = 1return = 2Example 2
H = [6, 5, 5, 4, 3]X = 8Y = 9return = 4Example 3
H = [6, 5, 2, 1, 8]X = 17Y = 5return = 5Example 4
H = [5, 5, 4, 6]X = 8Y = 8return = 2More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Maximum Strength of Every NeuronOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026