The most frequent tasks determine the idle structure.
Let maxf be the maximum frequency, and num_max the number of tasks with that frequency.
The minimum time is:
len(tasks) (if you can fill all idles),(maxf - 1) * (n + 1) + num_max.Arrange the most frequent task(s) in rows with n cooldown gaps; other tasks fill gaps if available.
The most frequent tasks determine the idle structure.
Let maxf be the maximum frequency, and num_max the number of tasks with that frequency.
The minimum time is:
len(tasks) (if you can fill all idles),(maxf - 1) * (n + 1) + num_max.Arrange the most frequent task(s) in rows with n cooldown gaps; other tasks fill gaps if available.