All submissions for this problem are available.Chef is on an adventure trip. Chef is going to climb a mountain and he can perform $N$ operations in any order and any number of times he wants **(possibly zero)**. A list of $N$ integers represent the operations. In each operation, Chef can climb or slip $A_i (1 \leq i \leq N)$ metres according to his choice. There is a cave at height $H$ metres. Since Chef is already tired due to his previous journeys, he wants to rest in the cave for some time. Chef wonders if it is possible to reach the cave or not. You need to process $Q$ queries. For every query, if Chef starts from the base ,print **"YES"** if it is possible to reach the cave, else print **"NO"**. ###Input: - The 1st line contains two integers $N$ and $Q$, the number of operations and the number of queries. - The next line contains $N$ space separated integers denoting the operations. - Next $Q$ lines contains the height of cave for each query. ###Output: For each query, print **“YES”** or **“NO”** in a new line (without quotes). ###Constraints - $1 \leq N,Q \leq 10^5$ - $1 \leq A_i,H \leq 10^9$ ###Subtasks - 100 points: **Original constraints** ###Sample Input: 2 2 9 12 3 11 ###Sample Output: YES NO ###EXPLANATION: For the first query, $H=3$, Chef climbs $12$ steps and then he slips by $9$ steps, hence he reaches the cave successfully. For the second query $H=11$, there's no way to reach the cave.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.