Description
Solutions
Bring Servers Down
🔥 FULLTIME

The developers at Amazon want to perform a reliability drill on some servers. There are n servers where the ith server can serve request[i] number of requests and has an initial health of health[i] units.

Each second, the developers send the maximum possible number of requests that can be served by all the available servers. With the request, the developers can also send a virus to one of the servers that can decrease the health of a particular server by k units. The developers can choose the server where the virus should be sent. A server goes down when its health is less than or equal to 0.

After all the servers are down, the developers must send one more request to conclude the failure of the application.

Find the minimum total number of requests that the developers must use to bring all the servers down.

Function Description

Complete the function minimumRequests in the editor.

minimumRequests has the following parameters:

  1. 1. int[] request: an array of integers representing the number of requests each server can serve
  2. 2. int[] health: an array of integers representing the initial health of each server
  3. 3. int k: an integer representing the health decrease caused by the virus

Returns

int: the minimum total number of requests to bring all the servers down

Example 1:

Input:  request = [3, 4], health = [4, 6], k = 3
Output: 21
Explanation:
The minimum number of requests required is 21.
Constraints:
    N/A
Thumbnail 0
Testcase

Result
Case 1

input:

output: