 # anumla problem

I have first sorted the array of subsets in decreasing order.
then the first element of this array s will contain sum of all elements that would be present in the original array.
the s will contain sum of (n-1)largest numbers of the original array
thus s-s will result in smallest element of the original array.
now s will contain sum of (n-2)largest elements & 1 smallest element of original array.
thus s-s will be the second smallest element of the original array.
similarly other elements of the array can be found.
but I am getting wrong answer for this approach.
please correct it, if any errors are there.
m solution link is http://www.codechef.com/viewsolution/5189854

this is in general wrong for instance let’s take small value of n=3 s.t. a=1,b=2,c=5 then according to you s=a+b+c which is true and the approach will continue to be true till s as s=a+c but this approach fails in this case when you reach s acc. to you s=a+b but actually s=c so s -s=a+b and not equal to c. 2 Likes