Please tell me the exact logic to solve this question. I've tried a lot but always end up with WA. Here is the link of the question  http://www.codechef.com/CDSU2015/problems/MHTBAG asked 31 Jan '15, 12:16

It w1 is odd, the we need one n1 object to fill the last one space. If n1==0, then the point is wasted. so, if w1 is odd, then subtract 1 from it (the last space), if n1>0, add 1 to answer and reduce one from n1. Do the same for w2. Now you have two bags each with even number weight capacity. Now, each object in n2 carries 2 units of weight. So total weight is 2*n2. Let, n2=2*n2; and W=w1+w2; So now, n2 and n1 are total weight available and W is the total weight capacity. If W<=n2, it means we can fill all the weight in W by n2. So, apply p.s. In solving with n2, if W becomes 0, it doesn't cause any problem with n1 part as we are adding and subtracting 0 from any value. answered 31 Jan '15, 15:05

Easy to understand Solution
answered 06 Jun '17, 21:22
