题目大意:给定一个长度为 N 的序列,现选出 M 个点组成一个集合,求这 N 个点到这个集合的最近距离的和是多少. 题解: 状态设计为 dp[i][j] 表示前 i 个点中选出 j 个点的最近距离和是多少,转移显然要枚举上一个选的点在哪里,即:\(dp[i][j]=min(dp[k][j-1]+cost(k+1,i))\).发现在枚举进行计算时,需要提前计算一个 cost(i,j),表示 [i,j] 这段区间内的点到只有一个被选点的最近距离是多少.cost 的计算只需预处理即可,每次取区间点的中…
Post Office Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18835 Accepted: 10158 Description There is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each vill…
http://noi.openjudge.cn/ch0206/162/ 总时间限制: 1000ms 内存限制: 65536kB 描述 There is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village is identified with a single integer…