You are viewing a single comment's thread. Return to all comments →
Bruh, this is Greedy I wasted my time in thinking how should I be applying dp : ( trying some kind of 0-1 Knapsack pattern or something else
Please try with Greedy approaches before checking the solution
Here's the solution in Python :
def mandragora(H): H.sort() currmax=tot=sum(H) s=1 for i in H: tot,s=tot-i,s+1 if tot*s>currmax: currmax=tot*s else: break return currmax
Seems like cookies are disabled on this browser, please enable them to open this website
Mandragora Forest
You are viewing a single comment's thread. Return to all comments →
Bruh, this is Greedy I wasted my time in thinking how should I be applying dp : ( trying some kind of 0-1 Knapsack pattern or something else
Please try with Greedy approaches before checking the solution
Here's the solution in Python :