Subset Sum

3.8

4 votes
Easy
Problem

The task is very simple you ar given an array of n numbers. You need to print all the unique subsets of the array having sum K in sorted order.
Note that each of the subset you print should be in sorted order also also a smaller subset should be printed first i.e all subsets should also be printed in sorted order.
A subset A is smaller than subset B if there exists A[i] < B[i] for the smallest possible i.
Please not that you only need to print unique subsets i/e dont print them twice if they accur more than once.
 

INPUT FORMAT - 

First line contains 2 integers N and K
Second line contains N space sperated integers


OUTPUT FORMAT -
Output unique subsets having sum K in sorted order


CONSTRAINTS - 

1N15

1K10000

1A[i]100

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?