{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n Heard that $eom$ is a fishing MASTER, you want to acknowledge him as your mentor. As everybody knows, if you want to be a MASTER\u0027s apprentice, you should pass the trial. So when you find fishing MASTER $eom$, the trial is as follow: \n \u003cbr\u003e \n \u003cbr\u003eThere are $n$ fish in the pool. For the $i$ - $th$ fish, it takes at least $t_i$ minutes to stew(overcook is acceptable). To simplify this problem, the time spent catching a fish is $k$ minutes. You can catch fish one at a time and because there is only one pot, only one fish can be stewed in the pot at a time. While you are catching a fish, you can not put a raw fish you have caught into the pot, that means if you begin to catch a fish, you can\u0027t stop until after $k$ minutes; when you are not catching fish, you can take a cooked fish (stewed for no less than $t_i$) out of the pot or put a raw fish into the pot, these two operations take no time. Note that if the fish stewed in the pot is not stewed for enough time, you cannot take it out, but you can go to catch another fish or just wait for a while doing nothing until it is sufficiently stewed. \n \u003cbr\u003e \n \u003cbr\u003eNow $eom$ wants you to catch and stew all the fish as soon as possible (you definitely know that a fish can be eaten only after sufficiently stewed), so that he can have a satisfying meal. If you can complete that in the shortest possible time, $eom$ will accept you as his apprentice and say \"I am done! I am full!\". If you can\u0027t, $eom$ will not accept you and say \"You are done! You are fool!\". \n \u003cbr\u003e \n \u003cbr\u003eSo what\u0027s the shortest time to pass the trial if you arrange the time optimally? \n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of input consists of a single integer $T(1 \\leq T \\leq 20)$, denoting the number of test cases. \n\u003cbr\u003e \n\u003cbr\u003eFor each test case, the first line contains two integers $n(1 \\leq n \\leq 10^5), k(1 \\leq k \\leq 10^9)$, denoting the number of fish in the pool and the time needed to catch a fish. \n\u003cbr\u003e \n\u003cbr\u003ethe second line contains $n$ integers, $t_1, t_2, \\dots , t_n(1 \\leq t_i \\leq 10^9)$ ,denoting the least time needed to cook the $i$ - $th$ fish."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print a single integer in one line, denoting the shortest time to pass the trial."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e2\n3 5\n5 5 8\n2 4\n3 3\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e23\n11\n\n\n \n \u003ci style\u003d\"font-size:1px\"\u003e \u003c/i\u003e\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cpre\u003e\nCase 1: Catch the 3rd fish (5 mins), put the 3rd fish in, catch the 1st fish (5 mins), wait (3 mins), \n\ntake the 3rd fish out, put the 1st fish in, catch the 2nd fish(5 mins), \n\ntake the 1st fish out, put the 2nd fish in, wait (5 mins), take the 2nd fish out.\n\nCase 2: Catch the 1st fish (4 mins), put the 1st fish in, catch the 2nd fish (4 mins), \n\ntake the 1st fish out, put the 2nd fish in, wait (3 mins), take the 2nd fish out.\n\n \n \u003c/pre\u003e"}}]}