2025-01-01 2025-01-01 problem 1 分钟读完 (大约120个字) 0次访问LC3218. 切蛋糕的最小总开销 I题目链接:3218. 切蛋糕的最小总开销 I 题解 [[LC3219. 切蛋糕的最小总开销 II]] 的简化版本 参考代码 123456789101112131415161718192021222324252627282930class Solution: def minimumCost(self, m: int, n: int, horizontalCut: List[int], verticalCut: List[int]) -> int: horizontalCut.sort() verticalCut.sort() cost = 0 i = 0 j = 0 while True: if m == 1 and n == 1: break # print(i, j, m, n) if n == 1: cost += horizontalCut[i] i += 1 m -= 1 elif m == 1: cost += verticalCut[j] j += 1 n -= 1 elif horizontalCut[i] < verticalCut[j]: cost += horizontalCut[i] * n i += 1 m -= 1 else: cost += verticalCut[j] * m j += 1 n -= 1 return cost LC3218. 切蛋糕的最小总开销 Ihttps://blog.xiang578.com/problem/lc3218.html作者Ryen Xiang发布于2025-01-01更新于2025-01-01许可协议 LeetCode, Problems/2025
2025-04-20@Towards Personalized and Semantic Retrieval: An End-to-End Solution for E-commerce Search via Embedding Learning随手记