Minimum Total Execution Time

Company: Barclays

Difficulty: medium

Problem Statement

Minimum Total Execution Time There are `n` processes that need to be executed. They are numbered `1` through `n` and, at the start, all `n` of them form a single contiguous array of processes that is assigned to one processor. Among these `n` processes, `k` are classified as **high-priority**. Their (1-based) numbers are given in the array `high_priority`. An OS scheduler oversees the execution of all processes. Whenever a set of processes `p` is assigned to a processor, the scheduler has exactly two options: **Split.** If the number of processes in `p` is greater than `1` **and** even, the scheduler may divide `p` into two contiguous subarrays of equal length, `p1` and `p2`, such that `p = [p1, p2]`. It then allocates `p1` to one processor and `p2` to another. Each of those two processors again faces the same two options for the array it received. **Execute.** Otherwise (or by choice), the processor simply executes the whole array `p`. The time a processor needs to execute an array `p