In the gym, Chef prefers to lift at least $W$ grams during a bench press and if that's impossible, Chef considers his workout to be incomplete and feels bad.

The rod weighs $W_{r}$ grams and there are $N$ other weights lying on the floor that weigh $w_{1}, w_{2}, ..., w_{N}$ grams. To maintain balance and to ensure that there is no unnecessary load due to torque, it's important that the weights added to the left side are symmetric to the weights added to the right side. It is not required to use all of the weights. It is also not required to use any weights at all, if Chef feels satisfied lifting only the rod.

For example:

- $1$ $2$ $2$ $1$ $|$Rod Center$|$ $1$ $1$ $1$ $3$ is a wrong configuration, but

- $1$ $2$ $3$ $1$ $|$Rod Center$|$ $1$ $3$ $2$ $1$ is a right configuration.

Find whether Chef will be able to collect the required weights to feel satisfied.

------ Input ------

The first line contains an integer $T$, the number of test cases. Then the test cases follow. 
Each test case contains two lines of input.
The first line contains three space-separated integers $N, W, W_{r}$.
The second line contains $N$ space-separated integers $w_{1}, w_{2}, \ldots, w_{N}$.

------ Output ------
For each test case, output the answer in a single line: "YES" if Chef will be satisfied after his workout and "NO" if not (without quotes).

You may print each character of each string in uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).

------ Constraints  ------
$1 ≤ T ≤ 10$
$1 ≤ N ≤ 10^{5}$
$1 ≤ W ≤ 2\cdot 10^{5}$
$1 ≤ w_{i} ≤ 10^{5}$
$1 ≤ W_{r} ≤ 2\cdot 10^{4}$

------ Subtasks ------
Subtask #1 (30 points): $w_{i} = 1$ for all valid $i$ 

Subtask #2 (70 points): original constraints

----- Sample Input 1 ------ 
3

2 5 10 

2 2

7 100 50

100 10 10 10 10 10 90 

6 100 40 

10 10 10 10 10 10
----- Sample Output 1 ------ 
YES

NO

YES
----- explanation 1 ------ 
Test case 1: Since the weight of the rod is at least the required weight to be lifted, Chef will feel satisfied after the workout.

Test case 2: The configuration having maximum weight is:

$10$ $10$ $|$Rod Center$|$ $10$ $10$

So the maximum total weight Chef can lift is $50 + 4 \cdot 10 = 90$ which is less than the required amount to get satisfied.

Test case 3: The configuration having maximum weight is:

$10$ $10$ $10$ $|$Rod Center$|$ $10$ $10$ $10$

So the maximum total weight Chef can lift is $40 + 6\cdot 10 = 100$ which is equal to the required amount to get satisfied.

Difficulty: MEDIUM_HARD
Tags: Data structures

Implementation

Greedy algorithms
Skill types: Data structures

Greedy algorithms

Starter code:

Solutions:
from collections import Counter
tc = int(input())
for _ in range(tc):
	(n, w, wr) = map(int, input().split())
	a = Counter(list(map(int, input().split())))
	if wr >= w:
		print('YES')
	else:
		d = 0
		for i in a:
			d += a[i] // 2 * i * 2
			if wr + d >= w:
				print('YES')
				break
		else:
			print('NO')


from collections import Counter
t = int(input())
for _ in range(t):
	(n, w, wr) = list(map(int, input().split()))
	arr = Counter(list(map(int, input().split())))
	if wr >= w:
		print('YES')
	else:
		s = 0
		for i in set(arr):
			s += arr[i] // 2 * i * 2
			if wr + s >= w:
				print('YES')
				break
		else:
			print('NO')


for _ in range(int(input())):
	(n, w, wr) = map(int, input().split())
	arr = list(map(int, input().split()))
	if w <= wr:
		print('YES')
	else:
		d = dict()
		for i in arr:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		for i in d:
			if d[i] >= 2:
				wr += d[i] // 2 * 2 * i
		if wr >= w:
			print('YES')
		else:
			print('NO')


from collections import Counter
for _ in range(int(input())):
	(N, W, Wr) = map(int, input().split())
	L = list(map(int, input().split()))
	D = dict(Counter(L))
	S = Wr
	FLAG = False
	for i in D.keys():
		if D[i] > 1:
			S += D[i] // 2 * 2 * i
		if S >= W:
			FLAG = True
			break
	if FLAG:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, w, wr) = map(int, input().split())
	k = list(map(int, input().split()))
	d = {}
	c = wr
	for h in k:
		if h in d:
			d[h] += 1
		else:
			d[h] = 1
	for t in d:
		if d[t] % 2 == 0:
			c += d[t] * t
	if c >= w:
		print('YES')
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	(n, w, wk) = map(int, input().split())
	l = list(map(int, input().split()))
	d = dict(Counter(l))
	s = wk
	done = False
	for i in d.keys():
		if d[i] > 1:
			s += d[i] // 2 * 2 * i
		if s >= w:
			done = True
			break
	if done:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, w, wr) = map(int, input().split())
	a = list(map(int, input().split()))
	if wr >= w:
		print('YES')
	else:
		w -= wr
		d = {}
		for i in a:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		s = 0
		for i in d:
			s += d[i] // 2 * i
		s *= 2
		if s < w:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	(n, w_min, w_rod) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	w = w_rod
	i = n - 1
	while i > 0:
		if a[i] == a[i - 1]:
			w += 2 * a[i]
			i -= 2
		else:
			i -= 1
		if w >= w_min:
			break
	if w >= w_min:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(useless, Wgoal, Wrod) = list(map(int, input().split()))
	weights = list(map(int, input().split()))
	Wgoal -= Wrod
	Num_dups = {}
	if Wgoal <= 0:
		print('YES')
	else:
		for i in range(len(weights)):
			try:
				Num_dups[weights[i]] += 1
				if Num_dups[weights[i]] == 2:
					Num_dups[weights[i]] = 0
					Wgoal -= 2 * weights[i]
					if Wgoal <= 0:
						print('YES')
						break
			except:
				Num_dups[weights[i]] = 1
			if i == len(weights) - 1:
				print('NO')


from collections import Counter

def sol(n, w, wr, weights):
	if w <= wr:
		return 'YES'
	counts = Counter(weights)
	total = wr
	for (wt, count) in counts.items():
		if count & 1:
			total += wt * (count - 1)
		else:
			total += wt * count
	return 'YES' if total >= w else 'NO'
for _ in range(int(input())):
	(n, w, wr) = map(int, input().split())
	weights = list(map(int, input().split()))
	print(sol(n, w, wr, weights))


from collections import Counter
nt = lambda x: 1 if x % 2 == 0 else 0
for i in range(int(input())):
	(n, w, wr) = map(int, input().split())
	b = list(map(int, input().split()))
	total = wr
	f = 0
	if w <= wr:
		print('YES')
	else:
		bb = Counter(b)
		for (k, v) in bb.items():
			if v >= 2:
				total += 2 * (k * (v // 2))
			if total >= w:
				f = 1
				break
		if f == 1:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, w, wr) = list(map(int, input().split()))
	wn = list(map(int, input().split()))
	if wr >= w:
		print('YES')
	else:
		rw = w - wr
		wn.sort()
		i = n - 1
		while i > 0 and rw > 0:
			if wn[i] == wn[i - 1]:
				rw -= wn[i] * 2
				i -= 2
			else:
				i -= 1
		if rw <= 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, w, wr) = [int(i) for i in input().split()]
	d = {}
	for i in input().split():
		i = int(i)
		if i in d.keys():
			d[i] = d[i] + 1
		else:
			d[i] = 1
	for i in d.keys():
		if d[i] % 2:
			d[i] -= 1
	l = list(d.items())
	for (ind, i) in enumerate(l):
		if i[1] == 0:
			l.pop(ind)
	sum = 0
	for i in l:
		sum += i[0] * i[1]
	if w > wr + sum:
		print('NO')
	else:
		print('YES')


for _ in range(0, int(input())):
	x = 0
	chef_lst = [int(i) for i in input().split()]
	bench_weight = [int(i) for i in input().split()]
	if chef_lst[1] <= chef_lst[2]:
		print('YES')
		continue
	bench_weight = sorted(bench_weight)
	new_weight = []
	for i in range(0, len(bench_weight) - 1, 2):
		if bench_weight[i] == bench_weight[i + 1]:
			new_weight.append(bench_weight[i])
	score = int(chef_lst[2])
	for i in range(0, len(new_weight)):
		score += 2 * int(new_weight[i])
		if score >= int(chef_lst[1]):
			print('YES')
			x = 1
			break
	if x == 1:
		continue
	print('NO')


for z in range(int(input())):
	(n, w, wr) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	if wr >= w:
		print('YES')
		continue
	w -= wr
	d = {}
	for x in a:
		if d.get(x) is None:
			d[x] = 0
		d[x] += 1
	b = 0
	for x in d.keys():
		if d[x] % 2 == 0:
			b += x * d[x]
		else:
			b += x * (d[x] - 1)
	if b >= w:
		print('YES')
	else:
		print('NO')


def Test(n, w, wr, arr):
	if wr >= w:
		return 'YES'
	else:
		arr.sort()
		data = {}
		for i in range(n):
			if arr[i] in data:
				data[arr[i]] += 1
			else:
				data[arr[i]] = 1
		ans = 0
		for (k, v) in data.items():
			if v == 1:
				continue
			elif v % 2 != 0:
				while True:
					if v % 2 == 0:
						break
					v -= 1
				ans += v * int(k)
			else:
				ans += v * int(k)
		if ans + wr >= w:
			return 'YES'
		return 'NO'
for _ in range(int(input())):
	(n, w, wr) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(Test(n, w, wr, arr))


for _ in range(int(input())):
	l = str(input()).split()
	n = int(l[0])
	w = int(l[1])
	wr = int(l[2])
	a = str(input()).split()
	a = list(map(int, a))
	freq = {}
	for i in a:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	if wr >= w:
		print('YES')
	else:
		max_wt = wr
		for i in freq.keys():
			if freq[i] % 2 == 0:
				max_wt += i * freq[i]
			else:
				max_wt += i * (freq[i] - 1)
		if max_wt >= w:
			print('YES')
		else:
			print('NO')


import os.path
from math import gcd, floor, ceil, log2
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	(n, W, Wr) = mp()
	iw = Wr
	wt = li()
	if W <= Wr:
		print('YES')
	else:
		rw = W - Wr
		d = dict(Counter(wt))
		fl = 0
		for (k, v) in d.items():
			if v >= 2:
				iw += 2 * k * (v // 2)
				if iw >= W:
					fl = 1
					break
		if fl:
			pr('YES')
		else:
			pr('NO')


from collections import Counter
t = int(input())
for i in range(t):
	(n, w, wr) = list(map(int, input().split()))
	lis = list(map(int, input().split()))
	pr = wr
	flag = 0
	counterkun = dict(Counter(lis))
	if wr >= w:
		flag = 1
	else:
		for j in counterkun.items():
			if j[1] >= 2:
				pr += 2 * j[0] * (j[1] // 2)
				if pr >= w:
					flag = 1
					break
	if flag:
		print('YES')
	else:
		print('NO')


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(n, w, r) = mp()
	l = li()
	if w <= r:
		pr('YES')
		return
	diff = w - r
	s = 0
	d = Counter(l)
	for i in d:
		if d[i] & 1:
			d[i] -= 1
		s += d[i] * i
		if s >= diff:
			pr('YES')
			return
	pr('NO')
for _ in range(inp()):
	solve()


import sys
from os import path
if path.exists('Input.txt'):
	sys.stdin = open('Input.txt', 'r')
	sys.stdout = open('Output.txt', 'w')
from math import gcd, floor, sqrt, log, ceil
import math
from collections import deque
read = lambda : int(input())
li = lambda : list(map(int, input().split()))
read2 = lambda : map(int, input().split())
M = 1000000007
(yes, no) = ('YES', 'NO')

def fact(n):
	return math.factorial(n)

def isPrime(n):
	if n % 2 == 0 and n != 2 or n < 2:
		return False
	i = 3
	while i * i <= n:
		if n % i == 0:
			return False
		i += 2
	return True

def solve():
	(n, w, wr) = read2()
	a = li()
	a.sort()
	if wr >= w:
		print(yes)
		return
	ans = 0
	d = dict()
	for i in range(n):
		if a[i] not in d:
			d[a[i]] = 1
		else:
			d[a[i]] += 1
		if d[a[i]] % 2 == 0:
			ans += a[i] * 2
	if ans + wr >= w:
		print(yes)
	else:
		print(no)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, w, wrod) = map(int, input().split())
	weights = [int(x) for x in input().split()]
	if wrod >= w:
		print('YES')
	else:
		wmap = {}
		wsum = wrod
		ans = 'NO'
		for i in weights:
			wmap[i] = 1 + wmap.get(i, 0)
		for (k, v) in wmap.items():
			possibleToAdd = wmap[k] // 2
			wsum += 2 * k * possibleToAdd
			if wsum >= w:
				ans = 'YES'
				break
		print(ans)


for i in range(int(input())):
	(N, w, W) = map(int, input().split())
	arr = list(map(int, input().split()))
	flag = 0
	d = {}
	for j in range(len(arr)):
		if arr[j] in d:
			d[arr[j]] += 1
		else:
			d[arr[j]] = 1
	if w <= W:
		print('YES')
	else:
		max_wt = W
		for j in d.keys():
			if d[j] % 2 == 0:
				max_wt += d[j] * j
			else:
				max_wt += (d[j] - 1) * j
		if max_wt >= w:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	l = str(input()).split()
	N = int(l[0])
	W = int(l[1])
	Wr = int(l[2])
	a = str(input()).split()
	a = list(map(int, a))
	m = {}
	for i in range(N):
		m[a[i]] = m.get(a[i], 0) + 1
	s = 0
	for i in m:
		s += i * (m[i] // 2)
	s *= 2
	if s + Wr >= W:
		print('YES')
	else:
		print('NO')


from collections import Counter

def answer_finder():
	(n, w, w_r) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	arr_new = Counter(arr)
	count = w_r
	for a_new in arr_new.keys():
		if arr_new[a_new] > 1 and arr_new[a_new] % 2 == 0:
			count += int(a_new) * arr_new[a_new]
	if count >= w:
		print('YES')
	else:
		print('NO')
test_cases = int(input())
while test_cases:
	test_cases -= 1
	answer_finder()


t = int(input())
for i in range(t):
	(n, wt, wr) = map(int, input().split())
	lst = sorted(list(map(int, input().split())))
	res = wr
	i = 0
	while i < n - 1:
		if lst[i] == lst[i + 1]:
			res += 2 * lst[i]
			i += 2
		else:
			i += 1
	if res >= wt:
		print('YES')
	else:
		print('NO')


def main():
	for _ in range(int(input())):
		(N, t, w) = map(int, input().split())
		arr = sorted(list(map(int, input().split())))
		res = w
		i = 0
		while i < N - 1:
			if arr[i] == arr[i + 1]:
				res += arr[i] * 2
				i += 2
			else:
				i += 1
		if res >= t:
			print('YES')
		else:
			print('NO')
main()


from collections import Counter
for _ in range(int(input())):
	(n, w, wr) = map(int, input().split())
	nli = list(map(int, input().split()))
	nli.sort()
	if wr >= w:
		print('YES')
	else:
		cnt = Counter(nli)
		for (key, value) in cnt.items():
			wr += 2 * key * (value // 2)
		if wr >= w:
			print('YES')
		else:
			print('NO')


for test in range(int(input())):
	(n, w, wr) = map(int, input().split())
	arr = [int(char) for char in input().split()]
	weight_required = w - wr
	dict = {}
	if weight_required <= 0:
		print('YES')
	else:
		for i in range(n):
			if arr[i] not in dict:
				dict[arr[i]] = 1
			else:
				dict[arr[i]] += 1
		weight = 0
		for word in dict:
			weight += 2 * (word * (dict[word] // 2))
		wr += weight
		if wr >= w:
			print('YES')
		else:
			print('NO')


t = int(input())
while t > 0:
	(n, w, wr) = map(int, input().split())
	arr = list(map(int, input().split()))
	dct = {}
	if wr >= w:
		print('YES')
	else:
		for i in range(n):
			if arr[i] not in dct:
				dct[arr[i]] = 1
			else:
				dct[arr[i]] += 1
		weight = 0
		for word in dct:
			weight += 2 * (word * (dct[word] // 2))
		wr += weight
		if wr >= w:
			print('YES')
		else:
			print('NO')
	t -= 1


import sys

def _input():
	return sys.stdin.readline().strip()

def main():
	for _ in range(int(_input())):
		(n, w, wr) = map(int, _input().split())
		lst = list(map(int, _input().split()))
		freq = {}
		for i in lst:
			if i not in freq:
				freq[i] = 1
			else:
				freq[i] += 1
		for lol in freq:
			if freq[lol] & 1:
				wr += (freq[lol] - 1) * lol
			else:
				wr += freq[lol] * lol
		if wr >= w:
			print('YES')
		else:
			print('NO')
main()


def Satisfaction(N, W, Wr, W_list):
	if N <= 1 and Wr == W:
		return 'YES'
	elif N <= 1 and Wr != W:
		return 'NO'
	elif sum(W_list) + Wr < W:
		return 'NO'
	else:
		p = W - Wr
		j = 0
		while j < N - 1:
			if p <= 0:
				return 'YES'
			if j < N - 1 and W_list[j] == W_list[j + 1]:
				p = p - 2 * W_list[j]
				j += 2
			else:
				j += 1
		if p <= 0:
			return 'YES'
		if j >= N - 1 and p > 0:
			return 'NO'
T = int(input())
for i in range(T):
	(N, W, Wr) = map(int, input().split())
	W_list = list(map(int, input().split()))
	W_list = sorted(W_list)
	result = Satisfaction(N, W, Wr, W_list)
	print(result)


for t in range(int(input())):
	(n, w, r) = map(int, input().split())
	l = [int(x) for x in input().split()]
	if w - r <= 0:
		print('YES')
	else:
		w -= r
		d = {}
		for x in l:
			if x in d:
				d[x] += 1
			else:
				d[x] = 1
		for (x, y) in d.items():
			if y % 2 == 0:
				w -= y * x
		if w <= 0:
			print('YES')
		else:
			print('NO')


from collections import Counter

def solve():
	dct = Counter(w)
	if W <= WR:
		print('YES')
	else:
		s = 0
		for ele in dct:
			s += int(ele) * (2 * (dct[ele] // 2))
		if s + WR >= W:
			print('YES')
		else:
			print('NO')
t = int(input())
for _ in range(t):
	(N, W, WR) = list(map(int, input().split()))
	w = list(map(str, input().split()))
	solve()


from collections import defaultdict

def f(n, w, wr, a):
	d = defaultdict(lambda : 0)
	for x in a:
		d[x] += 1
	s = 0
	for k in d.keys():
		if d[k] % 2 == 0:
			s += d[k] * k
		else:
			s += k * (d[k] - 1)
	if s + wr >= w:
		return True
	else:
		return False
t = int(input())
for i in range(t):
	(n, w, wr) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if f(n, w, wr, a) == True:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(n, w1, w2) = map(int, input().split())
	L = list(map(int, input().split()))
	if w2 >= w1:
		print('YES')
	else:
		S = set(L)
		M = list(S)
		d = {}
		for i in range(len(M)):
			d[M[i]] = 0
		L.sort()
		for i in range(n):
			d[L[i]] += 1
		w = w2
		i = 0
		while w < w1 and i < len(M):
			a = M[i]
			if d[a] % 2 == 0:
				w += a * d[a]
			i += 1
		if w >= w1:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	c1 = 1
	for i in range(a - 1):
		if l[i] == l[i + 1]:
			c1 += 1
		else:
			c += (c1 - (c1 & 1)) * l[i]
			c1 = 1
	c += (c1 - (c1 & 1)) * l[a - 1]
	if c >= b:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
import math
from collections import Counter
import functools
import time

def tr():
	return range(int(line()))

def sm():
	return map(int, line().split())

def ln():
	return list(sm())

def nl():
	return int(line())

def ssm():
	return map(str, line().split())

def line():
	return stdin.readline().rstrip()

def b(x):
	return bin(x).replace('0b', '')

def o(x):
	if type(x) != type(''):
		x = str(x)
	stdout.write(x + '\n')

def osp(x):
	if type(x) != type(''):
		x = str(x)
	stdout.write(x + ' ')

def ol(x):
	stdout.write(' '.join(map(str, x)))

def wline():
	return stdin.read().split()

def main():
	for _ in tr():
		(n, w, rod) = sm()
		weights = ln()
		if rod >= w:
			o('YES')
			continue
		counter = Counter(weights)
		max_weight = 0
		for i in counter:
			if counter[i] > 1:
				max_weight += i * (counter[i] // 2)
		if 2 * max_weight + rod >= w:
			print('YES')
		else:
			print('NO')
main()


class Solution:

	def func(self, arr, n, w, wr):
		if w - wr <= 0:
			return 'YES'
		remain_weight = w - wr
		wd = dict()
		for wi in arr:
			if wi not in wd.keys():
				wd[wi] = 1
			else:
				wd[wi] += 1
		for (weight, count) in wd.items():
			if count % 2 == 0:
				remain_weight -= weight * count
				if remain_weight <= 0:
					return 'YES'
		else:
			return 'NO'
t = int(input())
for _ in range(t):
	(n, w, wr) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	ob = Solution()
	ans = ob.func(arr, n, w, wr)
	print(ans)


from collections import Counter

def call(arr, n, W, wr):
	if W - wr <= 0:
		return 'YES'
	c = Counter(arr)
	s1 = 0
	for (key, value) in c.items():
		s1 += key * (value // 2) * 2
	if s1 + wr >= W:
		return 'YES'
	return 'NO'
t = int(input())
while t > 0:
	(n, W, wr) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	print(call(arr, n, W, wr))
	t -= 1


for _ in range(int(input())):
	(n, w, wr) = [int(a) for a in input().split()]
	arr = [int(a) for a in input().split()]
	d = {}
	for l in arr:
		if l in d:
			d[l] += 1
		else:
			d[l] = 1
	c = 0
	for l in d:
		c = c + d[l] // 2 * 2 * l
	if c + wr >= w:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, w, wr) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {}
	for item in a:
		if item not in d.keys():
			d[item] = 0
		d[item] += 1
	a = list(set(a))
	for item in a:
		if d[item] > 1:
			wr += item * 2 * (d[item] // 2)
	if wr >= w:
		print('YES')
	else:
		print('NO')


from math import ceil
from collections import Counter
for _ in range(int(input())):
	(n, w, wr) = map(int, input().split())
	l = list(map(int, input().split()))
	total = wr
	m = Counter(l)
	for i in set(l):
		p = int(m[i] / 2)
		total += p * i * 2
		if total >= w:
			break
	if total >= w:
		print('YES')
	else:
		print('NO')


try:
	for _ in range(int(input())):
		(n, w, r) = map(int, input().split())
		li = list(map(int, input().split()))
		li.sort()
		c = 1
		result = 0
		for i in range(n - 1):
			if li[i] == li[i + 1]:
				c += 1
			else:
				result = result + 2 * (c // 2) * li[i]
				c = 1
		result = result + 2 * (c // 2) * li[n - 1] + r
		if result >= w:
			print('YES')
		else:
			print('NO')
except:
	pass


for x in range(int(input())):
	(n, w, wr) = map(int, input().split())
	li = list(map(int, input().split()))
	flag = 0
	if wr >= w:
		flag = 1
	else:
		w -= wr
		count = 0
		li = sorted(li)
		for i in range(len(li)):
			count += 1
			if i == len(li) - 1 or li[i] != li[i + 1]:
				if count % 2 != 0:
					count -= 1
				w -= count * li[i]
				count = 0
				if w <= 0:
					flag = 1
					break
	if flag == 0:
		print('NO')
	else:
		print('YES')