there n pile stone arrange row the ith pile stonesi stonesA consist merge exactly k consecutive pile pile cost equal total number stone k pilesreturn minimum cost merge pile stone pile if impossible return 1 example 1input stone 3241 k 2output 20explanation we start 3 2 4 1we merge 3 2 cost 5 leave 5 4 1we merge 4 1 cost 5 leave 5 5we merge 5 5 cost 10 leave 10the total cost 20 minimum possibleExample 2input stone 3241 k 3output 1explanation after merge operation 2 pile leave can not merge anymore so task impossibleExample 3input stone 35126 k 3output 25explanation we start 3 5 1 2 6we merge 5 1 2 cost 8 leave 3 8 6we merge 3 8 6 cost 17 leave 17the total cost 25 minimum possible Constraintsn stoneslength1 n 301 stonesi 1002 k 30