Minimum Time to Execute Processes

Company: Rippling

Difficulty: medium

Problem Statement

Minimum Time to Execute Processes There are n processes and m processors. Process i has size processSize[i] for 0 <= i < n , and processor j has capacity capacity[j] for 0 <= j < m . A processor can execute a process in 1 second if the process size is at most the processor's capacity; otherwise it cannot execute that process. A processor may execute several processes one after another, but after completing a process it must pause for 1 second before starting the next one. Different processors work simultaneously. Implement getMinimumTime(processSize, capacity) , which returns the minimum number of seconds needed to execute all processes, or -1 if some process cannot be executed by any processor. Input Format The first line contains n . The second line contains the n values of processSize . The third line contains m . The fourth line contains the m values of capacity . Output Format Print one integer: the minimum completion time, or -1 when execution is impossible. Constrain