Company: Rippling_6aug
Difficulty: medium
Minimize Process Execution Time An operating system has to run n processes, numbered by their positions 1..n . Exactly k of them are high-priority processes; their distinct 1-based positions are given in highPriority (in any order). The scheduler works on contiguous segments of processes. For a segment [l, r] let length = r - l + 1 and let x be the number of high-priority processes inside it. For every segment it is handed, the scheduler either: runs the segment directly on one processor, or when length > 1 , splits it into two equal contiguous halves and hands each half to its own processor, where the same choice is made again. Running a segment directly costs: normalTime if x = 0 (the whole segment, whatever its length), priorityTime * x * length if x > 0 . The total time is the sum of the costs of all segments that are run directly. Because n is a power of two, every split produces two halves of equal length. Starting from the whole range [1, n] , find the minimum possible tot