I think this is a good dynamic programming problem for exercise🤔. One tricky point is that we can find the maximum number of ants that we can achieve when weight $ leq 10^{9} $ is around 138, which is much smaller than $10^{5}$. dp[i][j] means the minimum weight when we use ants from 1 to i to get a pile containing j ants. And the transition function is like dp[i][j] = min( dp[i-1][j], dp[i-1][j-1] + weights[i] (if 6*weights[i] $geq$ dp[i-1][j-1]))
近期评论