Introduction - If you have any usage issues, please Google them yourself
Problem Description: n heap stones placed around a playground. Now want to stone in order to merge into a pile. Provision for at least selected pile up election k to heap stones merger into a new pile of combined costs for the new pile of stones number. Try to design an algorithm to calculate the maximum total cost and minimum total cost of n heap stones combined into a pile. Programming tasks: For a given n heap stones, programming calculation merged into a bunch of maximum total cost and minimum total cost. Input test data the first row there are two positive integers n and k, n heap stones, each time at least one selected two heap up selected k heap stones merge. The second row has n numbers denote the number of each heap stones. Output Output maximum total cost and minimum total cost, separated by a space, each answer a row. Sample Input 7 3 45 13 12 16 9 5 22 Sample Output 593 1