#K37172. Exact Coin Collection
Exact Coin Collection
Exact Coin Collection
You are given ( n ) treasure chests, each containing a certain number of coins, and an integer ( t ). Your task is to determine if it is possible to exactly collect ( t ) coins by selecting a subset of these chests. This is a typical subset sum problem which can be solved using dynamic programming with a time complexity of ( O(n \times t) ).
inputFormat
Input is read from standard input. The first line contains two integers ( n ) and ( t ) separated by a space. The second line contains ( n ) space-separated integers representing the coin values in each treasure chest.
outputFormat
Output a single line to standard output containing either "YES" if it is possible to collect exactly ( t ) coins, or "NO" otherwise.## sample
5 700
100 200 300 400 500
YES