Post Office IOI 2000 /// 区间DP oj24077】的更多相关文章

题目大意: 给定n个村庄的坐标,两个村庄之间的距离是其坐标之差的绝对值 最多能选m个村庄设立邮局,求设立邮局的地点使得各村庄与邮局距离总和最小 一, 所有的村庄看做在一条直线上 考虑三个因素:i 当前位于第几个村庄,j 已设立邮局的个数,s 村庄与邮局的距离总和 即dp数组为 dp[ i ][ j ] = s  , 区间DP,枚举中间点村庄 k 则dp[ i ][ j ]=max{ dp[ k ][ j-1 ] + s( k+1,i ) | 0<k<i} (1~i村庄设j个邮局) 可由 (1~…
Post Office Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 22278 Accepted: 12034 Description There is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village…
很容易想到枚举第一步切掉的边,然后再计算能够产生的最大值. 联想到区间DP,令dp[i][l][r]为第一步切掉第i条边后从第i个顶点起区间[l,r]能够生成的最大值是多少. 但是状态不好转移,因为操作的符号不仅有‘+’,还有‘*’,加法的话,父区间的最大值显然可以从子区间的最大值相加得出. 乘法的话,父区间的最大值除了由子区间的最大值相乘得出,还可以由子区间的最小值相乘得出. 所以,多定义一维状态. dp[i][l][r][flag]表示第一步切掉第i条边后从第i个顶点起区间[l,r]能够生成…
题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2988 problem Description Flatland government is building a new highway that will be used to transport weapons from its main weapon plan…
QSC and Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 859    Accepted Submission(s): 325 Problem Description Every school has some legends, Northeastern University is the same. Enter…
Description FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given period time. The treats are interesting for…
Cheapest Palindrome poj-3280 题目大意:给出一个字符串,以及每种字符的加入代价和删除代价,求将这个字符串通过删减元素变成回文字符串的最小代价. 注释:每种字符都是小写英文字符,1<=代价cost<=1000,字符串长度<=2000. 想法:通过之前两道区间dp的铺垫,对区间dp有了一个大概的了解,但是这道题无疑是一道比较特别的区间dp. 首先,我们设dp状态,这显然是容易的:ans[i][j]表示将原字符串从i到j变成回文串的最小代价. 之后,我们考虑转移方程…
You Are the One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3348    Accepted Submission(s): 1524 Problem Description The TV shows such as You Are the One has been very popular. In order to m…
啊~~ 被dp摁在地上摩擦的人 今天做了一道区间dp的题(POJ1179Polygon) 题目: Polygon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6951   Accepted: 2975 Description Polygon is a game for one player that starts on a polygon with N vertices, like the one in Figure…
区间dp:顾名思义就是在区间上进行动态规划,通过合并小区间求解一段区间上的最优解. 常见模板: for(int len=1;len<n;len++){//区间长度 for(int be=1;be+len<=n;be++){//起点 int en=be+len;//终点 for(int j=be;j<en;j++){//割点 dp[be][en]=min(dp[be][en],dp[be][j]+dp[j+1][en]+割点代价);(max也可以) } } } http://www.51n…