动态规划——Warcraft
来源:互联网 发布:今日头条个人数据 编辑:程序博客网 时间:2024/06/06 02:48
Have you ever played the Warcraft?It doesn't matter whether you have played it !We will give you such an experience.There are so many Heroes in it,but you could only choose one of them.Each Hero has his own skills.When such a Skill is used ,it costs some MagicValue,but hurts the Boss at the same time.Using the skills needs intellegence,one should hurt the enemy to the most when using certain MagicValue.
Now we send you to complete such a duty to kill the Boss(So cool~~).To simplify the problem:you can assume the LifeValue of the monster is 100, your LifeValue is 100,but you have also a 100 MagicValue!You can choose to use the ordinary Attack(which doesn't cost MagicValue),or a certain skill(in condition that you own this skill and the MagicValue you have at that time is no less than the skill costs),there is no free lunch so that you should pay certain MagicValue after you use one skill!But we are good enough to offer you a "ResumingCirclet"(with which you can resume the MagicValue each seconds),But you can't own more than 100 MagicValue and resuming MagicValue is always after you attack.The Boss is cruel , be careful!
Now we send you to complete such a duty to kill the Boss(So cool~~).To simplify the problem:you can assume the LifeValue of the monster is 100, your LifeValue is 100,but you have also a 100 MagicValue!You can choose to use the ordinary Attack(which doesn't cost MagicValue),or a certain skill(in condition that you own this skill and the MagicValue you have at that time is no less than the skill costs),there is no free lunch so that you should pay certain MagicValue after you use one skill!But we are good enough to offer you a "ResumingCirclet"(with which you can resume the MagicValue each seconds),But you can't own more than 100 MagicValue and resuming MagicValue is always after you attack.The Boss is cruel , be careful!
4 2 2510 520 1030 2876 704 2 2510 520 1030 2877 700 0 0
4My god
Hint:When fighting,you can only choose one kind of skill or just to use the ordinary attack in the whole second,the ordinary attack costs the Boss 1 points of LifeValue,the Boss can only use ordinary attack which costs a whole second at a time.Good Luck To You!
题意:
英雄和boss初始都是100点血,英雄有100点蓝。
英雄有n个技能,第i个技能消耗a[i]点蓝,伤害是b[i]。
每回合英雄可以选择技能或普通攻击,普通攻击伤害是1但不耗蓝。
英雄每回合还可以恢复蓝量t,回蓝发生在英雄攻击之后。
boss的伤害每回合是固定的q,求英雄杀死boss的最短时间,若不能杀死,输出My god。
思路:设置dp[i][j]表示在i时间,剩余蓝量为j时对boss的最大伤害
则有dp[i][min(100, j+t-a[k])]=max(dp[i][min(100, j+t-a[k])], dp[i-1][j]+b[k]);
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;int n, t, q;int dp[110][110];int a[110];int b[110];int main(){ while(~scanf("%d%d%d", &n, &t, &q)&&(n+t+q)) { memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); memset(dp, -1, sizeof(dp)); for(int i=1; i<=n; i++) scanf("%d%d", &a[i], &b[i]); int time=100/q; if(100%q) time++; a[0]=0; //普通攻击也算作技能 b[0]=1; for(int i=0; i<=n; i++) if(a[i]<=100) dp[1][100-a[i]]=b[i]; //第一回合 for(int i=2; i<=time; i++) for(int j=0; j<=100; j++) for(int k=0; k<=n; k++) { if(dp[i-1][j]==-1) //若之前没出现过此状态就没法决策 continue; if(a[k]<=min(100, j+t)) dp[i][min(100, j+t-a[k])]=max(dp[i][min(100, j+t-a[k])], dp[i-1][j]+b[k]); } bool flag=false; for(int i=1; i<=time; i++) //找出最短时间 { for(int j=0; j<=100; j++) if(dp[i][j]>=100) { flag=true; printf("%d\n", i); break; } if(flag) break; } if(!flag) printf("My god\n"); } return 0;}
阅读全文
0 0
- 动态规划——Warcraft
- HDU 3008 动态规划(DP) Warcraft
- HDU 3008 Warcraft,动态规划,滚动数组
- HDU 3008 Warcraft (动态规划)【打怪类】
- hdu3008 Warcraft 【动态规划】【背包问题】
- 动态规划——什么是动态规划?
- 动态规划 — LIS
- 动态规划——Relocation 动态规划+状态压缩
- 动态规划——序
- 算法——动态规划
- 算法——动态规划
- 动态规划——最大值
- 动态规划——猴子
- POJ1036——动态规划
- 算法——动态规划
- 动态规划——hdu1003
- 算法——动态规划
- 算法——动态规划
- HDU 6060 RXD and dividing
- win7快捷键大全
- 整数、浮点型在内存中存储
- 用批处理批量替换文件中的某个字符串(亲自验证通过!完美!哈哈哈)
- AndroidStudio 插件集合 进行高效开发
- 动态规划——Warcraft
- 【HDU 1863】畅通工程(基础最小生成树,Kruskal算法)
- 【框架学习】springMVC过滤器与servlet拦截器区别
- mysql中复制表结构的方法小结
- JAVA 运行时报错:catch an exception java.util.ConcurrentModificationException
- 基尔霍夫矩阵计算欧拉回路
- PluginManager分析
- Android动画学习(六)之View揭露效果和SurfaceView实现动画
- C语言之从尾到头打印链表