TAKIN  Taskin and apple tree
Taskin has an apple orchard Every morning he goes to pick apples from orchard. He has a basket which can carry not more than M 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 T 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 a_{1} a_{2} a_{3} a_{n} where a_{i} is the number of apples in the ith tree.
Output
Print an integer, the maximum number of apples.
Example
Input
2 5 6 2 1 2 7 8 5 10 1 2 4 4 6
Output
5 10
hide comments
wisfaq:
20171212 12:11:49
@nadstratosfer:


nadstratosfer:
20171209 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 CPPwithfastIOorTLE type ones from the same genre that keep getting added here. 

Piyush Kumar:
20171209 16:15:37
I am not sure if this belongs to the classical section. 

morass:
20171204 13:09:10
Good day to you,

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