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

Only $x$ hours are left for the March Long Challenge and Chef is only left with the last problem unsolved. However, he is sure that he cannot solve the problem in the remaining time. From experience, he figures out that he needs exactly $H$ hours to solve the problem. 

Now Chef finally decides to use his special power which he has gained through years of intense yoga. He can travel back in time when he concentrates. Specifically, his power allows him to travel to $N$ different time zones, which are $T_{1}, T_{2}, \ldots, T_{N}$ hours respectively behind his current time.

Find out whether Chef can use one of the available time zones to solve the problem and submit it before the contest ends.

------  Input ------
The first line of the input contains three space-separated integers $N$, $H$ and $x$.
The second line contains $N$ space-separated integers $T_{1}, T_{2}, \ldots, T_{N}$.

------  Output ------
Print a single line containing the string "YES" if Chef can solve the problem on time or "NO" if he cannot.

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 ≤ N ≤ 100$
$1 ≤ x < H ≤ 100$
$1 ≤ T_{i} ≤ 100$ for each valid $i$

------  Subtasks ------
Subtask #1 (100 points): original constraints

----- Sample Input 1 ------ 
2 5 3
1 2
----- Sample Output 1 ------ 
YES
----- explanation 1 ------ 
Chef already has $3$ hours left. He can go to the $2$-nd time zone, which is $2$ hours back in time. Then he has a total of $3 + 2 = 5$ hours, which is sufficient to solve the problem.

----- Sample Input 2 ------ 
2 6 3
1 2
----- Sample Output 2 ------ 
NO
----- explanation 2 ------ 
If Chef goes to the $1$-st time zone, he will have $3 + 1 = 4$ hours, which is insufficient to solve the problem.

If he goes to the $2$-nd time zone, he will have $3 + 2 = 5$ hours, which is also insufficient to solve the problem.

Since none of the time travel options can be used to gain sufficient time to solve the problem, Chef is incapable of solving it.

Source: codechef | Difficulty: EASY
Tags: Mathematics

Implementation

Complete search


Solutions:
(N, H, x) = map(int, input().split())
lst = [int(i) for i in input().split()][0:N]
if H > x:
	for tz in lst:
		if x + tz >= H:
			print('YES')
			break
	else:
		print('NO')


(n, h, x) = map(int, input().split())
T = list(map(int, input().split()))
d = max(T)
if x + d >= h:
	print('YES')
else:
	print('NO')


(n, h, x) = map(int, input().split())
l = list(map(int, input().split()))
ans = 'NO'
for i in l:
	if i + x >= h:
		ans = 'YES'
		break
print(ans)


(N, H, x) = map(int, input().split())
t = list(map(int, input().split()))
more_time = max(t)
if H <= more_time + x:
	print('YES')
else:
	print('NO')


(x, y, z) = map(int, input().split())
l = list(map(int, input().split()))
a = 'NO'
for j in l:
	if j + z >= y:
		a = 'YES'
		break
print(a)


(n, h, x) = map(int, input().split())
t = list(map(int, input().split()))
c = 'NO'
for i in range(n):
	if t[i] + x >= h:
		c = 'YES'
		break
print(c)


(zones, hours_needed, hours_left) = map(int, input().split())
time = list(map(int, input().split()))[:zones]
flag = False
for zone in time:
	if zone + hours_left >= hours_needed:
		flag = True
		break
print('YES' if flag else 'NO')


(N, H, x) = map(int, input().split())
T = list(map(int, input().split()))
ans = 'NO'
for i in T:
	Z = x + i
	if Z >= H:
		ans = 'YES'
		break
print(ans)


(N, H, x) = map(int, input().split())
T = list(map(int, input().split()))
if H - x in T:
	print('YES')
else:
	print('NO')


(n, h, x) = map(int, input().split())
t = input().split()
flag = 0
for i in t:
	if int(i) + x >= h:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(n, h, x) = list(map(int, input().split()))
m = list(map(int, input().split()))
status = False
if h == x:
	print('YES')
else:
	for i in m:
		if i + x >= h:
			status = True
			break
		else:
			status = False
	if status == True:
		print('YES')
	else:
		print('NO')


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


(a, b, c) = map(int, input().split())
l = list(map(int, input().split()))
d = b - c
flag = 0
for i in l:
	if i >= d:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


(n, h, x) = map(int, input().split())
l = list(map(int, input().split()))
c = 'NO'
for i in l:
	if i + x >= h:
		c = 'YES'
print(c)


(N, H, x) = map(int, input().split())
T = map(int, input().split())
print('YES') if x + max(T) >= H else print('NO')


(N, H, x) = map(int, input().split())
T = list(map(int, input().split()))
for j in T:
	if j + x == H:
		print('YES')
		break
else:
	print('NO')


try:
	(n, h, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if h - x in l:
		print('YES')
	else:
		print('NO')
except:
	pass


(n, h, r) = map(int, input().split())
a = list(map(int, input().split()))
c = 0
for i in a:
	if i + r >= h:
		c = 1
if c == 1:
	print('YES')
else:
	print('NO')


(N, H, x) = map(int, input().split())
timezones = list(map(int, input().split()))
option = 0
success = 0
for i in range(N):
	option = x + timezones[i]
	if option >= H:
		print('YES')
		success += 1
		break
if success == 0:
	print('NO')


(n, h, x) = map(int, input().split())
lst = list(map(int, input().split()))
for t in lst:
	if t + x >= h:
		print('YES')
		break
else:
	print('NO')


l = list(map(int, input().split()))
Lm = max(list(map(int, input().split())))
print('YES' if Lm + l[-1] >= l[1] else 'NO')


(n, h, x) = map(int, input().split())
t = list(map(int, input().split()))
if max(t) + x >= h:
	print('YES')
else:
	print('NO')


(N, H, x) = map(int, input().split())
T = map(int, input().split())
result = 'NO'
for i in T:
	if i + x >= H:
		result = 'YES'
		break
print(result)


(n, h, x) = map(int, input().split())
l = [int(i) for i in input().split()]
if x + max(l) >= h:
	print('YES')
else:
	print('NO')


(n, h, x) = map(int, input().split())
time_zones = list(map(int, input().split()))
can_solve = any((ti + x >= h for ti in time_zones))
if can_solve:
	print('YES')
else:
	print('NO')


(x, y, z) = map(int, input().split())
l = list(map(int, input().split()))
f = 0
for i in l:
	if i + z >= y:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


(N, H, x) = map(int, input().split())
a = list(map(int, input().split()))
Bool = False
for i in a:
	if i >= H - x:
		Bool = True
		break
print('YES' if Bool == True else 'NO')


l1 = []
(N, H, x) = map(int, input().split())
l = list(map(int, input().split()))
for i in l:
	l1.append(i + x)
if H in l1:
	print('YES')
else:
	print('NO')


(a, b, c) = map(int, input().split())
l = list(map(int, input().split()))
for i in l:
	if i + c >= b:
		print('YES')
		break
else:
	print('NO')


(N, H, x) = map(int, input().split())
S = list(map(int, input().split()))
for i in S:
	if i + x >= H:
		print('YES')
		break
else:
	print('NO')


(n, h, x) = map(int, input().split())
arr = list(map(int, input().strip().split()))
arr.sort()
if arr[n - 1] + x == h:
	print('YES')
else:
	print('NO')


(a, b, c) = map(int, input().split())
x = list(map(int, input().split()))
if b - c in x:
	print('YES')
else:
	print('NO')


(n, h, x) = map(int, input().split())
list_a = list(map(int, input().split()))
res = 'NO'
for i in range(n):
	if list_a[i] + x >= h:
		res = 'YES'
		break
print(res)