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 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.
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 a1 a2 a3 . . . an where ai is the number of apples in the i-th tree.
Print an integer the maximum number of apples
2 1 2 7 8
1 2 4 4 6
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.
I am not sure if this belongs to the classical section.
Good day to you,