dp斜率优化 Hdu 3480 Division 题解

这篇博客介绍了如何利用dp斜率优化解决HDU在线评测平台上的3480题——Division。文章通过详细解释和样例,展示了如何通过对已排序数据进行动态规划和斜率优化,找到最小总成本的子集。
摘要由CSDN通过智能技术生成

累加器传送门:

http://blog.csdn.net/NOIAu/article/details/71775000


题目传送门:

https://vjudge.net/problem/HDU-3480


题目:

Little D is really interested in the theorem of sets recently. There’s a problem that confused him a long time.
Let T be a set of integers. Let the MIN be the minimum integer in T and MAX be the maximum, then the cost of set T if defined as (MAX – MIN)^2. Now given an integer set S, we want to find out M subsets S1, S2, …, SM of S, such that
这里写图片描述


and the total cost of each subset is minimal.

输入:

The input contains multiple test cases.
In the first line of the input there’s an integer T which is the number of test cases. Then the description of T test cases will be given.
For any test case, the first line contains two integers N (≤ 10,000) and M (≤ 5,000). N is the number of elements in S (may be duplicated). M is the number of subsets that we want to get. In the next line, there will be N integers giving set S.


输出:

For each test case, output one line containing exactly one integer, the minimal total cost. Take a look at the sample output for format.


样例输入:</

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值