I had GPT re-summarize the problem for me, so this is roughly what the first question looked like. It was pretty hard for me. I spent a long time just reading the statement, and it seems to be a new problem:
Problem Statement: A CPU needs to process n tasks, numbered from 1 to n.
There are k priority tasks, whose positions are given in the array priorityTasks.
The CPU can process a contiguous group of tasks using the following rules:
Normal processing: If a group contains no priority tasks, processing the entire group costs normalTime.
Priority processing: If a group contains priority tasks, processing it directly costs:
priorityTime * count * length
where count is the number of priority tasks in the group and length is the total number of tasks in that group.
Splitting: If a group contains more than one task, the CPU may divide it into two equal halves and process each half independently. Splitting itself has no additional cost.
Goal: Find the minimum total processing time required to process all n tasks.
The second question is the classic runway problem plus a difference array.
Hoping I pass.
Discussion
Loading comments…