Easy Peasy Subset Sum

Limits: 1s, 256 MB

Little Oishee loves to watch TV. But her mother, who is a math teacher, doesn’t like this at all. She thinks this way her daughter is being spoiled. So, she gave her this homework to keep her away from watching too much TV.

This is a companion discussion topic for the original entry at https://toph.co/p/easy-peasy-subset-sum

Can anyone explain the approch of solution and why this happen.I am weak in combinatorics so if anyone helps me.It will be helpful for me