I was trying solving the problem George and job of contest 467C. And my solution is : http://ideone.com/2cC2Fb I am using dp and finding out dp[k]* i.e. the maximum sum of k subsets of the size m from 1 to i in the given array input. Thus, that sum is computed as :
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?