Hints — p83 Task Scheduler
-
The most-frequent task drives the schedule. If it appears
f_maxtimes with cooldown n, you need at least(f_max - 1) * (n + 1) + 1slots to space them. -
If
ctasks tie atf_max, append them to the end:+cextra slots (one per tie). -
But if many distinct task types fill every idle, the answer is just
len(tasks). -
Closed form:
max(len(tasks), (f_max - 1) * (n + 1) + c). -
Heap simulation alternative: every cycle of n+1 time, pop the n+1 highest-count tasks, decrement, push back; idle the remainder if heap still non-empty.
If stuck: see solution.py.