#P6567. [NOI Online #3 入门组] 买表
[NOI Online #3 入门组] 买表
Problem Description
Jimmy goes to Symbol's watch shop to buy watches. Jimmy only brought types of coins. The face value of the -th type is yuan, and he has coins of that type. There are watches in Symbol's shop, and the price of the -th watch is yuan.
Symbol's watch shop cannot give change, so Jimmy can only buy a watch when he can make up exactly the required amount of money. Now, for each watch in the shop, Jimmy wants to know whether he can make up the exact amount to buy it.
Input Format
The first line contains two space-separated integers and , representing the number of coin types and the number of watches.
The next lines each contain two space-separated integers and , representing the face value and the count of the -th coin type.
The -th line contains space-separated integers , representing the price of each watch.
Output Format
Output a total of lines. For the -th line, output Yes if Jimmy can make up exactly the amount to buy the -th watch; otherwise output No. Note that only the first letter is uppercase.
3 5
1 2
5 1
6 3
3 19 21 1 7
No
Yes
No
Yes
Yes
Hint
Explanation for Sample 1
- For the second watch, , so it can be made up exactly.
- For the fourth watch, , so it can be made up exactly.
- For the fifth watch, , so it can be made up exactly.
Constraints
- For of the testdata, it is guaranteed that , , , , .
- For of the testdata, it is guaranteed that , , , , .
Notes
data provider: @Jiao Yue Ban Sa Hua.
Translated by ChatGPT 5