Welcome   HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online
Home
FAQs
Problem Set
Practices
Online Contests
Major Exercises
OI Special
Judgement
Submit
Online Status
User Ranklist
Users
Register new
Login
Web Links
Hunan Normal University
College of Information Science and Engineering
多元 Huffman编码问题
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB
Total submit users: 7, Accepted users: 4
Problem 11119 : No special judgement
Problem description
  在一个操场的四周摆放着n堆石子。现要将石子有次序地合并成一堆。规定每次至少选2堆最多选k堆石子合并成新的一堆,合并的费用为新的一堆的石子数。你的任务是计算将n堆石子合并成一堆的最大总费用和最小总费用。

Input
  有多组测试数据。每组的第一行是2个正整数nk,(1<= n<= 5001<= k<= 200)表示有n堆石子,每次至少选2堆最多选k堆石子合并。第2行有n个数,每个数不超过100,分别表示每堆石子的个数。

Output
  对每组测试数据,一行输出最大总费用和最小总费用。

Sample Input
7 3
45 13 12 16 9 5 22
Sample Output
593 199
Submit   Clarifications   Judge Status  Problems  Ranklist 

HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online, Version 2010.5.5.final.
Web visits:2019 today,12073068 total, since 2010-05-07