There are \(N\) types of money denomination in your country having values \(a_1, a_2, ...,a_n\). You went to a shop to buy a product worth \(P\)units, predict whether is it possible to complete the purchase or not (You and the shopkeeper can choose notes of each denomination any number of times). You need to process Q queries for this. Print "YES" if it is possible to complete the purchase, else print "NO".
Input Format
- First line contains two space-separated integers \(N\) and \(Q\)
- Second line contains n space-separated integers \(a_1, a_2, ...,a_n\)
- Next \(Q\) lines contains the value of \(P\) for each query.
Constraints
\(1 \le N \le 10^5 \)
\(1 \le Q \le 10^5 \)
\(1 \le a_i \le 10^9\)
For the first query, \(P = 3\), you give a note of \(9\) to the salesman and he returns \(6 \) to you, hence the purchase completed successfully.
For the second query, \(P = 4\), there's no way to complete the purchase.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor