In Chefland, there are N houses numbered from 1 to N, i^{th} house has a defence system having strength A_{i}. 

Chef suspects a bomb drop on one of the houses very soon. A bomb with attack strength X can destroy the i^{th} house, if the defence system of the i^{th} house A_{i}, is strictly less than X.

Also, when the i^{th} house is destroyed due to the bomb, all houses with indices j such that 1 ≤ j < i get destroyed as well irrespective of their defence system. 

Given one bomb with attack strength X, find the maximum number of houses that can get destroyed.

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

- The first line will contain T - the number of test cases. Then the test cases follow.
- First line of each test case contains 2 integers N , X.
- Second line of test case contains N space separated integers A_{1}, A_{2},\ldots ,A_{N}.

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

For each test case, output in a single line the maximum number of houses that can get destroyed if the bomb can hit any house.

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

$1 ≤ T ≤ 100$
$1 ≤ N ≤ 10^{5}$
$1 ≤ X ≤ 10^{9}$
$1 ≤ A_{i} ≤ 10^{9}$
- Sum of $N$ over all test cases does not exceed $10^{5}$

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

----- Sample Output 1 ------ 
6
0

----- explanation 1 ------ 
Test Case $1$: The bomb can only destroy houses $1, 2, 4,$ and $6$.
- If it hits house $1$, only house $1$ is destroyed.
- If it hits house $2$, houses $1$ and $2$ are destroyed.
- If it hits house $4$, houses $1, 2, 3$ and $4$ are destroyed.
- If it hits house $6$, houses $1, 2, 3, 4, 5,$ and $6$ are destroyed.

The maximum number of destroyed houses is $6$.

Test Case $2$: The  bomb cannot destroy any of the houses as the defence system of each house is not lesser than attack power of bomb. Thus, the total number of destroyed houses is $0$.

Difficulty: EASY
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
T = int(input())
for i in range(T):
	e = input().split(' ')
	N = int(e[0])
	X = int(e[1])
	N_space = input().split(' ')
	number = 0
	for i in range(int(N)):
		if int(N_space[i]) < X:
			number = 1 + i
	print(number)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	k = -1
	for i in range(n):
		if x > a[i]:
			k = i
	print(k + 1)


T = int(input())
for _ in range(T):
	(N, X) = map(int, input().split())
	A = list(map(int, input().split()))
	cnt = 0
	for i in range(N):
		if A[i] < X:
			cnt = i + 1
	print(cnt)


for t in range(int(input())):
	(houses, stren) = map(int, input().split())
	arr = list(map(int, input().split()))[:houses]
	cou = 0
	for i in range(houses):
		if stren > arr[i]:
			cou = i + 1
	print(cou)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	N = list(map(int, input().split()))
	m = 0
	for i in range(n):
		if N[i] < x:
			m = i + 1
	print(m)


t = int(input(''))
for i in range(t):
	l = [-1]
	(N, X) = map(int, input().split())
	lst = [int(j) for j in input().split()][:N]
	for k in range(len(lst)):
		if lst[k] < X:
			l.append(k)
	print(max(l) + 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = input().split()
	flag = 0
	for j in range(n - 1, -1, -1):
		if int(a[j]) < x:
			flag = j + 1
			break
	print(flag)


for i in range(int(input())):
	s = []
	res = [0]
	(n, x) = map(int, input().split(' '))
	s.extend(map(int, input().split(' ')))
	for j in range(len(s)):
		if s[j] < x:
			res.append(j + 1)
	print(max(res))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = 0
	i = 0
	for i in range(n):
		if a[i] < x:
			s = i + 1
	print(s)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	temp = 0
	for i in range(n - 1, -1, -1):
		if l[i] < x:
			temp = 1
			print(i + 1)
			break
	if temp == 0:
		print(0)


t = int(input())
for i in range(t):
	(N, X) = map(int, input().split())
	A = list(map(int, input().split()))
	c = 0
	for j in range(N - 1, -1, -1):
		if A[j] < X:
			c = j + 1
			break
	print(c)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	for i in range(n):
		if l[i] < x:
			c = i + 1
	print(c)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l1 = list(map(int, input().split()))
	ans = 0
	for i in range(n):
		if l1[i] < x:
			ans = i + 1
		else:
			pass
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = [int(c) for c in input().split()]
	count = 0
	for i in range(a):
		if c[i] < b:
			count = i + 1
	print(count)


from array import *
t = int(input())
for i in range(t):
	(N, X) = map(int, input().split())
	A = [int(i) for i in input().split()]
	A.reverse()
	for i in range(N):
		if X > A[i]:
			break
		else:
			i = N
	print(N - i)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	cnt = 0
	for i in range(n - 1, -1, -1):
		if x > arr[i]:
			cnt = i + 1
			break
	print(cnt)


n = int(input())
while n > 0:
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	m = 0
	for i in range(0, a):
		if l[i] < b:
			m = i + 1
	print(m)
	n = n - 1


t = int(input())
for i in range(t):
	(N, X) = map(int, input().split())
	A = list(map(int, input().split()))
	i = 0
	attack_house = 0
	while i < N:
		if A[i] < X:
			attack_house = i + 1
		i = i + 1
	print(attack_house)


t = int(input())
while t:
	t -= 1
	destruction = -1
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	for i in range(n):
		if x > arr[i]:
			destruction = i
	print(destruction + 1)


T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	Li = list(map(int, input().split()))
	res = 0
	for i in range(N - 1, -1, -1):
		if Li[i] < X:
			print(i + 1)
			res = 1
			break
	if res == 0:
		print(res)


for t in range(int(input())):
	(N, X) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	for j in range(N):
		if a[j] < X:
			c = j + 1
	print(c)


for _ in range(int(input())):
	(h, s) = map(int, input().split())
	x = list(map(int, input().split()))
	ans = -1
	for i in range(h):
		if x[i] < s:
			ans = i
		else:
			pass
	print(ans + 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	list1 = list(map(int, input().split()))
	count = 0
	for j in range(len(list1)):
		if list1[j] < x:
			count = j + 1
	print(count)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	i = n - 1
	k = -1
	while i in range(n - 1, -1, -1) and k == -1:
		if x > a[i]:
			k = i
		i -= 1
	print(k + 1)
	t -= 1


a = int(input())
for i in range(a):
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	a = 0
	for i in range(x[0] - 1, -1, -1):
		if y[i] < x[1]:
			a = i + 1
			break
	print(a)


t = int(input())
for _ in range(t):
	i = list(map(int, input().split()))
	houses = list(map(int, input().split()))
	for j in range(i[0] - 1, 0 - 1, -1):
		if houses[j] < i[1]:
			print(j + 1)
			break
		if j == 0:
			print(0)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	t = n - 1
	count = 0
	while t >= 0:
		if a[t] < x:
			print(t + 1)
			count += 1
			break
		t -= 1
	if count == 0:
		print('0')


for t in range(int(input())):
	(n, x) = map(int, input().split())
	tmp = list(map(int, input().split()))
	count = 0
	for i in range(n):
		if tmp[i] < x:
			count = i + 1
	print(count)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	m = 0
	for i in range(n):
		if a[i] < x:
			m = i + 1
	print(m)


for i in range(int(input())):
	(N, X) = map(int, input().split(' '))
	A = list(map(int, input().split(' ')))
	M = 0
	for j in range(N):
		if A[j] < X:
			M = j + 1
	print(M)


t = int(input())
for z in range(t):
	(n, x) = map(int, input().split(' '))
	A = list(map(int, input().split()))
	ans = 0
	for i in range(n):
		if A[i] < x:
			ans = i + 1
		else:
			continue
	print(ans)


for i in range(int(input())):
	(N, X) = map(int, input().split())
	A = list(map(int, input().split()))
	k = -1
	for i in range(N):
		if X > A[i]:
			k = i
	print(k + 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	at = 0
	for i in range(n):
		if a[i] < x:
			at = i + 1
	print(at)


T = int(input())
for _ in range(T):
	(N, X) = map(int, input().split())
	A = list(map(int, input().split()))
	count = 0
	for i in A[::-1]:
		if i < X:
			print(N - count)
			break
		else:
			count = count + 1
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	houses = [int(x) for x in input().split()]
	destroyed = []
	try:
		for j in range(len(houses)):
			if houses[j] < x:
				destroyed.append(j + 1)
		print(max(destroyed))
	except:
		print(0)


for x in range(int(input())):
	(Se, Vi) = map(int, input().split())
	Ha = list(map(int, input().split()))
	count = 0
	for x in range(len(Ha)):
		if Vi > Ha[x]:
			count = x + 1
	print(count)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	count = 0
	for i in range(len(l)):
		if b > l[i]:
			count = i + 1
	print(count)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	for j in range(n):
		if a[j] < x:
			c = j + 1
	print(c)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	z = []
	for i in range(n):
		if a[i] < x:
			z.append(i)
	if len(z) > 0:
		print(max(z) + 1)
	else:
		print(0)


for i in range(int(input())):
	(N, X) = map(int, input().split())
	l = list(map(int, input().split()))
	a = 0
	for i in range(N):
		if X > l[i]:
			a = i + 1
	print(a)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().rstrip().split()))
	arr.reverse()
	s = 0
	y = len(arr)
	for j in arr:
		if j < x:
			s = s + 1
			y = arr.index(j)
			break
	print(len(arr) - y)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	ans = -1
	for i in range(a - 1, -1, -1):
		if c[i] < b:
			ans = i
			break
	print(ans + 1)


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().strip().split())
	l = list(map(int, input().strip().split()))
	s = 0
	for i in range(0, len(l)):
		if l[i] < k:
			s = i + 1
	print(s)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	for j in range(n):
		if x > l[-(1 + j)]:
			print(len(l) - j)
			break
		elif j == n - 1:
			print(0)
		else:
			pass


for x in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	list = [int(x) for x in input().split()]
	m = 0
	for i in range(n):
		if list[i] < x:
			m = i + 1
	print(m)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	for j in range(a):
		if l[j] < b:
			c = j + 1
	print(c)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in range(x - 1, -1, -1):
		if l[i] < y:
			print(i + 1)
			break
		elif i == 0:
			print('0')


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	for (j, i) in reversed(list(enumerate(l))):
		if i < x:
			print(j + 1)
			break
		else:
			c += 1
	if c == n:
		print(0)


for i in range(int(input())):
	(number, bomb) = map(int, input().split())
	lis = list(map(int, input().split()))
	res = 0
	for i in range(len(lis) - 1, -1, -1):
		if bomb > lis[i]:
			res = i + 1
			break
	print(res)


for t in range(int(input())):
	(n, x) = map(int, input().split(' '))
	li = list(map(int, input().split(' ')))
	count = len(li)
	for i in range(len(li) - 1, -1, -1):
		if li[i] < x:
			break
		count -= 1
	print(count)


try:
	t = int(input())
	for r in range(t):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		c = 0
		for i in range(n):
			if a[i] < x:
				c = i + 1
		print(c)
except:
	pass