#K59062. Counting Subsets with a Given Sum

    ID: 30781 Type: Default 1000ms 256MiB

Counting Subsets with a Given Sum

Counting Subsets with a Given Sum

You are given an array of N integers and a target integer T. Your task is to determine the number of distinct subsets (including the empty subset) from the array whose sum is exactly T. Since the answer can be very large, output it modulo $$10^9+7$$.

A subset is defined as any selection of elements from the array (order does not matter). For example, if the array is [1, 2, 3, -1, 5] and T = 3, there are 3 subsets which sum to 3.

Note that each element in the array can be used at most once in forming a subset.

inputFormat

The first line of input contains two integers N and T, representing the number of elements in the array and the target sum respectively.

The second line contains N space‐separated integers indicating the elements of the array.

outputFormat

Output a single integer: the number of subsets whose sum equals T, taken modulo $$10^9+7$$.

## sample
5 3
1 2 3 -1 5
3

</p>