Subset sum - MarisaOJ: Marisa Online Judge

Subset sum

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers, your task is to determine whether there exists a subset of $A$ whose sum is equal to $k$. ### Input - The first line contains two integers $n,k$. - The second line contains $n$ integers $A_i$. ### Output - Print YES if there exists a subset of $A$ whose sum is equal to $k; otherwise, print `NO`. ### Constraints - $1 \le n \le 20$. - $1 \le A_i,k \le 10^{18}$. ### Example Input: ``` 4 7 1 2 3 4 ``` Output: ``` YES ```