Completion Order with Concurrency Limit

JavaScript Hard 4 views
Back to Questions

Problem Description

You have n task durations and limit k. Start first k tasks. When one finishes, start next. Print total time in first line, and completion order of task indices (1-based) in second line.

Input Format

Line1: n k. Line2: n integers durations.

Output Format

Line1: totalTime. Line2: completionOrder.

Sample Test Case

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

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next