Given an array of **N** positive integers a1, a2 ............ an. The value of each contiguous subarray of given array is the **maximum element present in that subarray**. The task is to return the number of subarrays having value strictly greater than **K**.

**Input:**

The first line of the input contains '**T**' denoting the total number of testcases. Then follows the description of testcases. The first line of each testcase contains two space separated positive integers N and K denoting the size of array and the value of K. The second line contains N space separated positive integers denoting the elements of array.

**Output:**

Output the number of subarrays having value strictly greater than K.

**Constraints:**

1 <= T <= 50

1 <= N <= 100

1 <= a[i] <= 10^{5}

**Example:**

**Input: **

2

3 2

3 2 1

4 1

1 2 3 4

**Output:**

3

9

**Explanation:
Testcase 1**: The subarrays having value strictly greater than K are: [3], [3, 2] and [3, 2, 1]. Thus there are 3 such subarrays.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

sabka_din_aayega | 309 |

maggiiiii | 230 |

Anugrah_kumar | 172 |

UtkarshMalik | 150 |

Savage_19 | 146 |

Bishnu Dev Panda | 777 |

sabka_din_aayega | 620 |

Anugrah_kumar | 562 |

okayboss | 552 |

yk12 | 514 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.