All Tracks Algorithms Dynamic Programming Introduction to Dynamic Programming 1 Problem

Xsquare And Coin Collection
/

Ad-Hoc, Implementation

Problem
Editorial
Analytics

Xsquare loves to play with the coins very much. Today , he has N stacks of coins . Each stack of coins has some non zero height Hi equal to the number of coins on that stack ( considering all the coins are identical and each coin has a height of 1 unit ) .

In one move, Xsquare can select any number of consecutive stacks of coins such that the height of each selected stack of coins Hi ≤ K . Once such a sequence of stacks is chosen , Xsquare can collect any number of coins from the chosen sequence of stacks .

Xsquare wonders what is the maximum number of coins that he can collect this way ?

INPUT

First line of input contains a single integer T denoting the number of test cases . First line of each test case contains two space separated integers N and K where N being the number of stacks of coins. Second line of each test case contains N space separated integers denoting the number of coins Hi on each stack .

OUTPUT

For each test case , Print the maximum number of coins Xsquare can collect following the above gaming strategy.

CONSTRAINTS

1 ≤ T ≤ 105

1 ≤ N ≤ 105

1 ≤ K ≤ 109

1 ≤ Hi ≤ 109

Note :

sum of N over all the test case will not exceed 106.

SAMPLE INPUT
2
8 1
3 2 2 3 1 1 1 3
8 2
3 2 2 3 1 1 1 3
SAMPLE OUTPUT
3
4

Explanation

Test 1 : N = 8 , K = 1 3 2 2 3 1 1 1 3 We can collect coins from stacks numbered 5 , 6 and 7 .

Test 2 : N = 8 , K = 2 3 2 2 3 1 1 1 3 We can collect coins from stacks numbered 2 and 3 .

Time Limit: 3.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?