Run Tasks with Concurrency Limit

JavaScript Medium 4 views
Back to Questions

Problem Description

Given n tasks durations (ms) and a limit k, simulate running tasks with max k parallel workers. Print total time taken.

Input Format

Line1: n k. Line2: n integers durations.

Output Format

One integer total time.

Sample Test Case

Input:
5 2 3 2 4 1 2
Output:
7

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next