hdu 4283"You Are the One"(区间DP)】的更多相关文章

传送门 https://www.cnblogs.com/violet-acmer/p/9852294.html 题意: 有n个屌丝排成一排,每个屌丝都有一个不开心值a[ i ]( i=1,2,3,.....n ),如果第 i 个屌丝第 k 个上场,那么他的不开心度就是(k-1)*a[ i ]. ∑ni=1(ki-1)*a[i]的最小值,其中ki指的是第i个屌丝第k个上场. 关键条件"the director can put the boy into the dark room temporari…
参考了许多大佬  尤其是https://blog.csdn.net/woshi250hua/article/details/7973824这一篇 ,最后我再加一点我的见解. 大意是 给定一个序列,序列内的人有屌丝值Di,将这个序列进栈,第i个人如果是第k个出栈,那么最后的屌丝总值增加Di * (k-1), 求一个出栈序列使得总屌丝值最小. 这一题用到了一个性质,如果第1个人确定了是第k个出栈,那么第2~k个人一定在他之前出栈,而且k+1~n个人一定在他之后出栈.这个可以随便拿纸模拟一下来得出结论…
You Are the One Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the…
http://blog.csdn.net/acm_cxlove/article/details/7964594 http://www.tuicool.com/articles/jyaQ7n http://blog.csdn.net/woshi250hua/article/details/7973824 记忆化搜索(15MS): #include <iostream> #include <string> #include <cstring> #include <cs…
题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=4283 Problem Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small…
题目链接   http://acm.hdu.edu.cn/showproblem.php?pid=5900 题意:给出序列$A_{i}.key$和$A_{i}.value$,若当前相邻的两个数$A_{i}.key$和$A_{i+1}.key$的最大公约数大于1,则可以把这两个数消去,同时消去$A_{i}.value$和$A_{i+1}.value$,每次消去得到的分数为$A_{i}$和$A_{i+1}$的value值,问最大可能得分. 注意:当$A_{i}$和$A_{i+1}被$消去后,$A_{…
题意:你是一个战士现在面对,一群狼,每只狼都有一定的主动攻击力和附带攻击力.你杀死一只狼.你会受到这只狼的(主动攻击力+旁边两只狼的附带攻击力)这么多伤害~现在问你如何选择杀狼的顺序使的杀完所有狼时,   自己受到的伤害最小.(提醒,狼杀死后就消失,身边原本相隔的两只狼会变成相邻,而且不需要考虑狼围城环这种情况) 题解:明显的区间DP,但是这题中需要自己确定一个 方案,不难想到先打2边在打中间: 子问题:在区间i,j上的代价: 划分:区间的直接合并的过程中,是区间和区间合并还是区间和点合并,即分…
题意:查找这样的子回文字符串(未必连续,但是有从左向右的顺序)个数. 简单的区间dp,哎,以为很神奇的东西,其实也是dp,只是参数改为区间,没做过此类型的题,想不到用dp,以后就 知道了,若已经知道[0,i],推[0,i+1], 显然还要从i+1 处往回找,dp方程也简单:  dp[j][i]=(dp[j+1][i]+dp[j][i-1]+10007-dp[j+1][i-1])%10007; 减去中间一段重复的  if(s[i]==s[j])dp[j][i]=(dp[j][i]+dp[j+1][…
题目链接: 黑书 P116 HDU 2157 棋盘分割 POJ 1191 棋盘分割 分析:  枚举所有可能的切割方法. 但如果用递归的方法要加上记忆搜索, 不能会超时... 代码: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; const int inf=6400*6400; const int N=8; int sum[1…
String painter Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2068    Accepted Submission(s): 908 Problem Description There are two strings A and B with equal length. Both strings are made up o…