Company: Yellow.ai
Difficulty: medium
Concurrent Promise Scheduler A server is responsible for executing multiple tasks. The server has K workers , and each worker can process only one task at a time. You are given the execution time required for N tasks . Tasks are assigned to workers in the order they are received. When a task arrives: It is assigned to the worker who becomes available the earliest. If multiple workers are available at the same time, assign the task to any one of them. Once assigned, a task runs to completion without interruption. Your objective is to determine the minimum total time required to complete all tasks . All workers are idle at time 0 , and a worker picks up its next task the instant it becomes free. (inferred — the source does not say when the workers start or whether idling is allowed; both follow from the stated assignment rule and are needed for the sample outputs) Input Format The first line contains two integers: N K Where: N = Number of tasks K = Number of available workers The second