Very nice question

Today is Chocolate day and Kabir and Tara are visiting a Valentine fair. Upon arriving, they find a stall with an interesting game.

There are N jars having some chocolates in them. To win the game, one has to select the maximum number of consecutive jars such that the sum of count of chocolates in maximum and second maximum jar is less than or equal to k in that range.

Kabir wants to win the game so that he can gift the chocolates to Tara. You are a friend of Kabiir, help him win the game. There will be at least one possible answer.

Note :

You have to select at least two jars.
Count of chocolates in maximum and second maximum jar among selected consecutive jars may be equal.
Input:
First line will contain T, number of test cases.
First line of each test case contains two space separated integers N,k.
Second line of each test case contains N space separated integer ai denotes number of chocolates in the jar.
Output:
For each test case print maximum number of jars.

Constraints:
1≤T≤10
2≤N≤105
1≤ai≤105
Sample Input:
1
6 5
1 3 3 1 1 5

Sample Output:
3
Last edited on
any updates???
duplicate thread.
the original thread is still waiting on the Op to post his code, so I do not think there are any updates yet.
Topic archived. No new replies allowed.