Try each possible speed from 1 to max(piles). For each speed, calculate the total hours needed.
There are up to possible speeds. Checking each takes . Total: .
That's up to operations. Far too slow.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
The trap
Try each possible speed from 1 to max(piles). For each speed, calculate the total hours needed.
There are up to possible speeds. Checking each takes . Total: .
That's up to operations. Far too slow.