Maximize Number of Produced Cars
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?
Write a function:
class Solution { public int solution(int[] H, int X, int 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.
1Example 1
2Example 2
3Example 3
4Example 4
Constraints
Limits and guarantees your solution can rely on.
- N is an integer within the range [1..1,000];
- each element of array H is an integer within the range [1..1,000];
- X and Y are integers within the range [1..500].