can anyone explain…how to do this question…http://www.codechef.com/DTCT2015/problems/SUPERCUP

or what this guy did in his code…http://www.codechef.com/viewsolution/6785795

1 Like

the upper limit of n wasn’t too big n<=40.

so we can divide the array in 2 equal parts.(n1=n/2,n2=n-n1)

now we can calculate sum of all possible subset bcz 2^20~10^5

and then combine(by binary search or whatever u can do in timelimit) these two array to get required ans.