#K65237. Subsequence Sum Existence

    ID: 32153 Type: Default 1000ms 256MiB

Subsequence Sum Existence

Subsequence Sum Existence

Given a sequence of (N) integers, determine whether there exists a non-empty subsequence whose sum equals a target value (T). A subsequence is defined as any subset of the original sequence (the elements need not be contiguous). Formally, find if there exists a subset (S) of indices such that (\sum_{i \in S} a_i = T).

inputFormat

The first line contains two space-separated integers: (N) (the number of elements) and (T) (the target sum). The second line contains (N) space-separated integers representing the sequence.

outputFormat

Print (YES) if there exists at least one non-empty subsequence with sum equal to (T); otherwise, print (NO).## sample

5 8
3 -4 5 7 -2
YES