|
|
вернуться в форумDid you use DP to solve this problem? How did you do it? use greedy algo instead. choose the largest numbers for the innermost square roots so that their values get depreciated with each iteration. this is how i did. sort arr in reverse order [code deleted] cur is the final answer Edited by moderator 19.10.2019 19:45 you can use dp in this task, like in the classical task "how to multiply n matrices in optimal way". it's O(n^3), so suitable. also there's greddy algorithm, O(n). |
|
|