I.e for a given K, i’ll get the maximum of the addition of sum (k-1) subset which ends at j-size, size here is m +sum[j] which is basically the subset [j-size,j]. Either I am including this or I am not including thi, the deciding factor is the maximum sum. I am getting WA on 22nd test case. I thought it’s exceeding the range, and so made it unsigned long long int also, but then it gives Memory limit exceeded. I went across one of the solution, I only saw the memory used by the arrays and it was the same as of my code. Then, why such error?
If n=1 and k=1 then will the answer be the last number??
Consider the following test case:
3 1 1
3 2 1
Clearly the answer is 3. But your code gives 1!
I dint look further into the code after seeing this error!
Dont forget up upvote and accept! ;)