Description
Solutions
Get Minimum Cost

The data analysts of Hackerland want to schedule some long running tasks on remote servers optimally to minimize the cost of running them locally. The analysts have two servers, a paid one and a free one. The free server can be used only if the paid server is occupied.

The task is expected to take time units of time to complete and the cost of processing the task on the paid server is cost. The task can be run on the free server only if some task is already running on the paid server. The cost of the free server is 0 and it can process any task in 1 unit of time.

Find the minimum cost to complete all the tasks if tasks are scheduled optimally.

Function Description

Complete the function getMinimumCost in the editor.

getMinimumCost has the following parameters:

  1. 1. int[] time: an array of integers representing the time units required for each task
  2. 2. int[] cost: an array of integers representing the cost of processing each task on the paid server

Returns

int: the minimum cost to complete all tasks

Example 1:

Input:  time = [3, 2, 3, 2], cost = [1, 2, 3, 2]
Output: 3
Explanation:
The first task must be scheduled on the paid server for a cost of 1 and it takes 3 units of time to complete. In the meantime, the other three tasks are executed on the free server for no cost as the free server takes only 1 unit to complete any task. Return the total cost, 1.
Constraints:
    TO-DO
Thumbnail 0
Testcase

Result
Case 1

input:

output: