I’m currently working on Moorio Kart. Looking at the official solution, I understand everything except where it says
Such an algorithm would run in O(YS) where S is equal to the sum of the number of distinct path lengths in each tree (when we group together lengths ≥Y ). S is maximized to be Nsqrt(Y) when we have trees of size sqrt(Y).
Why is the sum of the number of distinct paths minimized when trees are of size sqrt(Y)?