LogiQuest

214. Subset Sum

MediumDynamic Programming

Print YES if some subset of the positive numbers sums exactly to s, else NO.

Input format

Line 1: n s Line 2: n positive integers

Output format

YES or NO

Example 1

Input

6 9
3 34 4 12 5 2

Output

YES

Example 2

Input

6 30
3 34 4 12 5 2

Output

NO

Constraints

1 ≤ n ≤ 100 1 ≤ s ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…