Get Minimum Time
Given n processes that need to be executed. Among these n processes,
k are classified as high-priority processes, with their indices (1-based) represented
in the array as high_priority[i].
An OS scheduler is responsible for overseeing the execution of all processes. When a scheduler assigns a set of processes to a processor, it has two options:
p, into two contiguous subarrays of equal length, p1 and
p2, such that p = [p1, p2]. The scheduler will then allocate p1
to one processor and p2 to another.p.
The time required for process execution is determined based on the following criteria:
👉 1. If the assigned processes do not include any high-priority processes, the scheduler will take
normal_time seconds to complete all the assigned processes.
👉 2. If there are high-priority processes among the assigned tasks (denoted as x), it
will take (priority_time * x * l) seconds to complete them, where l is
the total number of assigned processes.
The total time required to execute all processes is the sum of the time taken by all processors for their assigned tasks. The task is to minimize the total execution time by optimizing the assignment of processes to processors within the operating system and return this minimum possible execution time.
Complete the function getMinimumTime in the editor below.
getMinimumTime takes the following parameters:
int n: the total number of processesint high_priority[k]: the indices of the high-priority processesint normal_time: the time factor for completing non-high-priority processesint priority_time: the time factor for completing high-priority processes
Returns
int: the minimum total execution time by optimizing the assignment of processes to
processors within the operating system
1Example 1
Constraints
Limits and guarantees your solution can rely on.
1 ≤ n ≤ 10^9nis a power of 21 ≤ k ≤ min(n, 10^5)1 ≤ high_priority[i] ≤ n