摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2159思路:dp[j][l]表示消耗了j忍耐度,杀了l个怪后获得的经验值;最后只要对dp扫一遍,找出是否有大于等于n的值,如果有,这保留此时的消耗的忍耐值;否则,输出-1;View Code 1 #include<iostream> 2 const int N=110; 3 using namespace std; 4 struct Node{ 5 int value,cost; 6 }node[N]; 7 int dp[N][N]; 8 9 int main(){10 int ... 阅读全文
posted @ 2013-03-11 21:06 ihge2k 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1176与数塔类似,但采用自下而上的方法更好,更方面,状态转移方程:dp[i][j]=max{dp[i+1][j],dp[i+1][j-1],dp[i+1][j+1]}+value[i][j];其中dp[i][j]表示第i秒时在位置j时包里的烧饼;View Code 1 #include<iostream> 2 #include<algorithm> 3 const int N=100010; 4 using namespace std; 5 6 int value[N][11 阅读全文
posted @ 2013-03-11 18:54 ihge2k 阅读(484) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2084自下而上,状态转移方程:dp[i][j]=max(dp[i+1][j]+map[i][j],dp[i+1][j+1]+map[i][j]);View Code 1 #include<iostream> 2 #include<algorithm> 3 const int N=110; 4 using namespace std; 5 int map[N][N],dp[N][N]; 6 7 int main(){ 8 int _case; 9 scanf("%d& 阅读全文
posted @ 2013-03-11 17:04 ihge2k 阅读(717) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1069其实,说白了,就是求最长单调子序列。。。思路:先排序之后,直接用经典的求最长单调子序列的方法求即可;View Code 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 struct Node{ 5 int l,w,h; 6 }node[1000]; 7 int dp[1000]; 8 9 int cmp(const Node &a,const Node &b){10 阅读全文
posted @ 2013-03-11 16:24 ihge2k 阅读(453) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2571其实,只要把状态转移方程写出来就ok了:dp[i][j]=max{dp[i][j],dp[i-1][j]+map[i][j],dp[i][j-1]+map[i][j],dp[i][k]+map[i][j](j%k==0)};View Code 1 #include<iostream> 2 #include<algorithm> 3 const int inf=0x7fffff; 4 using namespace std; 5 6 int map[22][1010]; 阅读全文
posted @ 2013-03-11 09:32 ihge2k 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1087一开始我把题目理解错了,还以为是必须连续的,orz。。。。思路:dp[i]表示第i个位置是的最大值,那么状态转移方程即为:dp[i]=dp[i-1]+num[i](num[i]>num[j],i>j);View Code 1 #include<iostream> 2 const int N=1100; 3 using namespace std; 4 int dp[N],num[N]; 5 6 int main(){ 7 int n; 8 while(scanf(&qu 阅读全文
posted @ 2013-03-11 08:56 ihge2k 阅读(192) 评论(0) 推荐(0) 编辑