## TAKIN - Taskin and apple tree

no tags

Taskin has an apple orchard . Every morning he goes to pick apples from orchard. He has a basket which can carry not more than K apples. Taskin pick apples, and put them into the basket. Taskin goes to each tree and either pick all the apples from that tree or skips that tree.  what is the maximum number of apples taskin can pick.

### Input

in the first line there will be an integer number of testcases
for every test case there will be 2 integers in the first line N and M , number of apple tree in the orchard and capacity of basket respectively.
next line contains N integers a1 a2 a3 . . . an where ai is the number of apples in the i-th tree.

$\\&space;T&space;\leq&space;10&space;\\&space;N&space;\leq&space;20&space;\\&space;M&space;\leq&space;2\times&space;10^{10}&space;\\&space;A_{i}&space;\leq&space;10^{9}$

### Output

Print an integer the maximum number of apples

### Example

Input:25 62 1 2 7 85 101 2 4 4 6

Output:510


hide comments
 wisfaq: 2017-12-12 12:11:49 @nadstratosfer: N<=40 would have made for a better problem, imho. Last edit: 2017-12-12 12:13:04 nadstratosfer: 2017-12-09 16:49:03 You probably got the correct approach right away, going by the status most people don't. I've been somewhat flabbergasted about what changes to my code resulted in bettering the runtime, but I see it as a plus. It's a tricky problem, a welcome change from CPP-with-fast-IO-or-TLE type ones from the same genre that keep getting added here. Piyush Kumar: 2017-12-09 16:15:37 I am not sure if this belongs to the classical section. morass: 2017-12-04 13:09:10 Good day to you, Even though it is well understandable as it it, I'm convinced the "K" shall be replaced by "M" (or vice versa) :P Good Luck & Have Nice Day!

 Added by: sabbir Date: 2017-12-03 Time limit: 1s Source limit: 50000B Memory limit: 1536MB Cluster: Cube (Intel G860) Languages: All