mid=⌊max(array)+min(array)2⌋, where max and min — are capacities that track down the maximum and the base array components. At the end of the day, mid is the amount of the maximum and the base component of array separated by 2 adjusted down. Then, at that point, the array is parted into two parts left and
Correct answer will be upvoted else Multiple Downvoted. Computer science.
assume mid=⌊max(array)+min(array)2⌋, where max and min — are capacities that track down the maximum and the base array components. At the end of the day, mid is the amount of the maximum and the base component of array separated by 2 adjusted down.
Then, at that point, the array is parted into two parts left and right. The left array contains all components which are not exactly or equal mid, and the right array contains all components which are greater than mid. Components in left and right maintain their relative control from array.
During the third step we pick which of the left and right arrays we want to keep. The picked array replaces the current one and the other is permanently discarded.
You want to assist Mike with discovering the aftereffects of q beauty tests.
Note that you test the attractiveness of the array a, so you start each beauty test with the primordial (initial) array a. Consequently, the primary cut (whenever required) is always performed on the array a.
Input
Each test contains at least one experiments. The main line contains the number of experiments t (1≤t≤100).
The main line of each experiment contains two integers n and q (1≤n,q≤105) — the length of the array an and the total number of beauty tests.
The second line of each experiment contains n integers a1,a2,...,an (1≤
Next q lines of each experiment contain a solitary integer si (1≤si≤109) — the amount of components which Mike wants to get in the I-th test.
It is guaranteed that the amount of n and the amount of q doesn't surpass 105 (∑n,∑q≤105).
Output
Print q lines, each containing either a "Yes" if the relating attractiveness test is passed and "No" in the contrary case.
Step by step
Solved in 4 steps with 1 images