Example 1: Input:num = 4325Output:59Explanation:We can split 4325 so thatnum1is 24 andnum2is 35, giving a sum of 59. We can prove that 59 is indeed the minimal possible sum. Example 2: Input:num = 687Output:75Explanation:We can split 687 so thatnum1is 68 andnum2is 7, which w...
The incompatibility is (2-1) + (4-1) = 4. Note that [1,1] and [2,4] would resultina smallersum, but the first subset contains 2 equal elements. Example 2: Input: nums = [6,3,8,1,3,1,2,2], k = 4 Output: 6 Explanation: The optimal distribution of subsets is [1,2], ...
代码参考: 1classSolution {2public:3//dp[i][j]:0~i workers to do map_j jobs: the min time cost4//dp[i][j]=min( <for all subj> : max(dp[i-1][subj],sum[j-subj]) ) subj:subset of j5//one worker to do sum[j-subj] and others have the min time cost: dp[i-1][subj...