diff --git "a/leetcode3/\354\206\241\354\243\274\355\230\234/3857. Minimum Cost to Split into Ones" "b/leetcode3/\354\206\241\354\243\274\355\230\234/3857. Minimum Cost to Split into Ones" new file mode 100644 index 00000000..0af5d409 --- /dev/null +++ "b/leetcode3/\354\206\241\354\243\274\355\230\234/3857. Minimum Cost to Split into Ones" @@ -0,0 +1,15 @@ +class Solution: + def minCost(self, n: int) -> int: + dp = [0] * (n+1) + + for i in range(2, n+1): + max_v = 1e9 + + for j in range(1, i): + cost = j*(i-j) + dp[j] + dp[i-j] + + if cost < max_v: + max_v = cost + + dp[i] = max_v + return dp[n]