Bomb the base solution codechef – In Chefland, there are NN houses numbered from 11 to NN, ithith house has a defence system having strength AiAi.

Bomb the base solution codechef

In Chefland, there are NN houses numbered from 11 to NNithith house has a defence system having strength AiAi.

Chef suspects a bomb drop on one of the houses very soon. A bomb with attack strength XX can destroy the ithith house, if the defence system of the ithith house AiAi, is strictly less than XX.

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

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

Input Format

  • The first line will contain TT – the number of test cases. Then the test cases follow.
  • First line of each test case contains 22 integers N,XN,X.
  • Second line of test case contains NN space separated integers A1,A2,,ANA1,A2,…,AN.

Output Format Bomb the base solution codechef

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

  • 1T1001≤T≤100
  • 1N1051≤N≤105
  • 1X1091≤X≤109
  • 1Ai1091≤Ai≤109
  • Sum of NN over all test cases does not exceed 105105

Sample Input 1  Bomb the base solution codechef

2
8 6
4 1 6 1 6 5 6 8
2 1
3 5

Sample Output 1 

6
0

Explanation Bomb the base solution codechef

Test Case 11: The bomb can only destroy houses 1,2,4,1,2,4, and 66.

  • If it hits house 11, only house 11 is destroyed.
  • If it hits house 22, houses 11 and 22 are destroyed.
  • If it hits house 44, houses 1,2,31,2,3 and 44 are destroyed.
  • If it hits house 66, houses 1,2,3,4,5,1,2,3,4,5, and 66 are destroyed.

The maximum number of destroyed houses is 66.

Test Case 22: 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 00.

For Solution

Click Here

Leave a Comment