#C7737. Exact Water Supply Problem
Exact Water Supply Problem
Exact Water Supply Problem
You are given N water stations and a target water volume W (in liters) needed for a race. Each station i provides a specific volume of water Vi. Your task is to determine whether it is possible to select a subset of these stations such that the sum of their water volumes equals exactly W liters.
This can be formulated as finding a subset S such that
$$\sum_{i \in S} V_i = W$$
If such a subset exists, print Yes
; otherwise, print No
.
inputFormat
The input is provided via standard input (stdin) in the following format:
- The first line contains two integers N and W, where N is the number of water stations and W is the total volume of water required.
- The second line contains N space-separated integers representing the water volumes V available at each station.
outputFormat
Output a single line to standard output (stdout) containing either Yes
if it is possible to supply exactly W liters of water using some of the stations, or No
otherwise.## sample
5 100
20 30 50 10 20
Yes