Let be the maximum frequency and be the number of tasks with that frequency. The minimum time is: . Why? The most frequent task creates gaps of size , plus the final batch of tasks.
If other tasks fill the gaps, the formula gives total tasks. Otherwise, idle time is needed. Time: . Space: .