Problem H
Stamp Combinations

You’re on your way to pick up a package from the store, wrap it, and mail it. You want to bring a certain number of stamps to mail it, and you have a long roll of stamps that you can use. Now, over time, you’ve occasionally pulled off a stamp from somewhere in the middle of the roll, and now you’re left with a strip where stamps are clustered in groups, separated by empty spaces.
Being practical, you don’t want to tear individual stamps, and so you’ll only tear the roll in between the clusters of stamps. And, you don’t want to be left with multiple rolls of stamps, so you can only pull these groups off of the beginning or end of the roll. Is it possible to do this with the roll of stamps you have?
Input
The first line of input consists of two integers,
The second line contains
The next
Output
For each query, output one line containing “Yes” if it is possible to bring that number of stamps, or ‘No” if it is not possible to bring that number of stamps.
Explanation of Sample
The roll contains
A group of
A group of
A group of
A group of
It is not possible to take just
Sample Input 1 | Sample Output 1 |
---|---|
5 5 2 8 1 3 3 2 10 5 17 1 |
Yes Yes Yes Yes No |