You are given a multiset of task types represented by uppercase letters (e.g., A, A, A, B, B, C). Each task takes exactly 1 time unit to execute. Running the same task type requires at least c cooldown time units between two executions of that type. You may reorder tasks and insert idle slots as needed. Compute the minimum total time units to finish all tasks. Describe an algorithm, justify its correctness, analyze time and space complexity, and explain how to construct one optimal schedule.