Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.

Chef will have N guests in his house today. He wants to serve at least one dish to each of the N guests. Chef can make two types of dishes. He needs one fruit and one vegetable to make the first type of dish and one vegetable and one fish to make the second type of dish. Now Chef has A fruits, B vegetables, and C fishes in his house. Can he prepare at least N dishes in total?

------ Input Format ------ 

- First line will contain T, number of testcases. Then the testcases follow.
- Each testcase contains of a single line of input, four integers N, A, B, C.

------ Output Format ------ 

For each test case, print "YES" if Chef can prepare at least N dishes, otherwise print "NO". Print the output without quotes.

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ N, A, B, C ≤ 100$

------ subtasks ------ 

Subtask 1 (100 points): Original constraints

----- Sample Input 1 ------ 
4
2 1 2 1
3 2 2 2
4 2 6 3
3 1 3 1

----- Sample Output 1 ------ 
YES
NO
YES
NO
----- explanation 1 ------ 
Test case $1$: Chef prepares one dish of the first type using one fruit and one vegetable and another dish of the second type using one vegetable and one fish.

Test case $2$: Chef prepares two dishes of the first type using two fruit and two vegetable. Now all the vegetables are exhausted, hence he can't prepare any other dishes.

Test case $3$: Chef can prepare a total of $5$ dishes, two dishes of the first type and three dishes of the second type.

Difficulty: EASY
Tags: Constructive algorithms

Mathematics

Ad-hoc

Starter code:

Solutions:
for _ in range(int(input())):
	(n, x, y, z) = map(int, input().split())
	d = x + z
	if n <= d and n <= y:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, a, b, c) = map(int, input().split())
	if b >= n and a + c >= n:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, a, b, c) = map(int, input().split())
	if n <= min(b, a + c):
		print('YES')
	else:
		print('NO')


goals = int(input())
for distractions in range(goals):
	(wife, aim, life, stress) = map(int, input().split())
	death = 0
	while death != wife:
		if aim != 0 and life != 0:
			aim -= 1
			life -= 1
		elif stress != 0 and life != 0:
			life -= 1
			stress -= 1
		else:
			break
		death += 1
	if death == wife:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(N, a, b, c) = map(int, input().split())
	d = 0
	while d != N:
		if a != 0 and b != 0:
			a -= 1
			b -= 1
		elif c != 0 and b != 0:
			b -= 1
			c -= 1
		else:
			break
		d += 1
	if d == N:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	(n, a, b, c) = map(int, input().split())
	total1 = a + c
	if total1 >= n:
		if b >= n or b >= total1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


T = int(input())
for t in range(T):
	(a, b, c, d) = map(int, input().split())
	x = b + d
	if c >= a and x >= a:
		print('YES')
	else:
		print('NO')


t = int(input(''))
for i in range(0, t):
	x = str(input('')).split()
	l = []
	for j in x:
		l.append(int(j))
	dish1 = 0
	dish2 = 0
	if l[2] >= l[0] and l[3] + l[1] >= l[0]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	ans = 'NO'
	if c >= a:
		if b + d >= a:
			ans = 'YES'
	print(ans)


def two_dishes(n, a, b, c):
	k = a + c
	if k > b:
		no_of_dish = b
	elif k <= b:
		no_of_dish = k
	if no_of_dish >= n:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	(n, a, b, c) = map(int, input().split())
	print(two_dishes(n, a, b, c))


t = int(input())
for _ in range(t):
	(n, a, b, c) = map(int, input().split())
	mn1 = min(a, b)
	a -= mn1
	b -= mn1
	mn2 = min(b, c) if b > 0 else 0
	if mn1 + mn2 >= n:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	l = list(map(int, input().split()))
	if l[2] >= l[0] and l[1] + l[3] >= l[0]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	(n, a, b, c) = map(int, input().split())
	d = 0
	if b >= n and a + c >= n:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	x = list(map(int, input().split()))
	c = x[0]
	b = x[1]
	n = x[2]
	f = x[3]
	v = 0
	while b > 0 and n > 0:
		b = b - 1
		n = n - 1
		v = v + 1
	if n == 0:
		if v >= c:
			print('YES')
		else:
			print('NO')
	else:
		while n > 0 and f > 0:
			n = n - 1
			f = f - 1
			v = v + 1
		if v >= c:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(N, A, B, C) = map(int, input().split())
	if B >= A + C and A + C >= N:
		print('YES')
	elif B < A + C and B >= N:
		print('YES')
	else:
		print('NO')


p = int(input())
while p:
	(n, a, b, c) = map(int, input().split())
	if a + c >= n and b >= n:
		print('YES')
	else:
		print('NO')
	p -= 1


from sys import stdin, stdout
input = stdin.readline
r_int = lambda : int(input())
m_int = lambda : map(int, input().split())
l_int = lambda : list(map(int, input()).split())

def solve():
	(n, a, b, c) = m_int()
	if min(a + c, b) < n:
		print('NO')
	else:
		print('YES')

def main():
	n_cases = r_int()
	for _ in range(n_cases):
		solve()
main()


for i in range(int(input())):
	(N, F, V, FI) = map(int, input().split())
	if V >= N and F + FI >= N:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, a, b, c) = list(map(int, input().split()))
	count = 0
	if a < b:
		count += a
		b -= a
	else:
		count += b
		b = 0
		if count >= n:
			print('YES')
		else:
			print('NO')
		t -= 1
		continue
	if b > 0:
		count += min(b, c)
		if count >= n:
			print('YES')
		else:
			print('NO')
		t -= 1
		continue


t = int(input())
while t > 0:
	(n, a, b, c) = input().split()
	(n, a, b, c) = [int(n), int(a), int(b), int(c)]
	dish1 = 0
	dish2 = 0
	while a:
		if b != 0:
			dish1 = dish1 + 1
			b = b - 1
		a = a - 1
	while c:
		if b != 0:
			dish2 = dish2 + 1
			b = b - 1
		c = c - 1
	if dish1 + dish2 >= n:
		print('YES')
	else:
		print('NO')
	t = t - 1


for i in range(int(input())):
	k = list(map(int, input().split()))
	f = 0
	n = k[0]
	a = k[1]
	b = k[2]
	c = k[3]
	while a > 0:
		if b > 0:
			a -= 1
			b -= 1
			f += 1
		else:
			break
	while b > 0:
		if c > 0:
			b -= 1
			c -= 1
			f += 1
		else:
			break
	if f >= n:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, f, v, fi) = map(int, input().split())
	if v >= n and f + fi >= n:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, a, b, c) = map(int, input().split())
	m1 = min(a, b)
	s = 0
	s = s + m1
	b = b - m1
	if b >= c:
		s = s + min(b, c)
		if s >= n:
			print('YES')
		else:
			print('NO')
	else:
		s = s + min(b, c)
		if s >= n:
			print('YES')
		else:
			print('NO')
	t = t - 1


import math
t = int(input())
while t > 0:
	(n, a, b, c) = map(int, input().split())
	d = a + c
	if n <= d and n <= b:
		print('YES')
	else:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	(N, f, v, fish) = map(int, input().split())
	if N <= v and N <= fish + f:
		print('YES')
	else:
		print('NO')


t = int(input())
for k in range(t):
	(n, a, b, c) = list(map(int, input().split()))
	if b - c > a:
		d = c + a
	else:
		d = c + (b - c)
	if d < n:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	fm = min(b, c)
	print('YES') if min(b, c) + min(c - fm, d) >= a else print('NO')


t = int(input())
for i in range(t):
	(n, a, b, c) = [int(x) for x in input().split()]
	r = a + c
	if r >= n and b >= n:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	(N, A, B, C) = [int(x) for x in input().split()]
	if B >= N:
		if A + C >= N:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	(n, f, v, fi) = list(map(int, input().split()))
	if v < n:
		print('NO')
	elif f + fi >= n:
		print('YES')
	else:
		print('NO')