
Warcraft
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 957 Accepted Submission(s): 487
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!
10 5
20 10
30 28
76 70
4 2 25
10 5
20 10
30 28
77 70
0 0 0
My 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!
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int a[],b[];
int dp[][]; //代表到第 i 秒剩余 j 魔法值打掉BOSS的HP
int main()
{
int n,t,q;
while(cin>>n>>t>>q){
if(n== && t== && q==)
break;
for(int i=;i<=n;i++)
cin>>a[i]>>b[i];
//freopen("output.txt","w",stdout);
memset(dp,-,sizeof(dp));
dp[][]=; //刚开始的时候出了MP=100,其余都为无效
int T;
if(%q==)
T=/q;
else
T=/q+;
int i,j,k;
for(i=;i<=T;i++){ //最多到100秒
for(j=;j<=;j++){ //一次遍历dp[i-1][0..100]的所有情况
if(dp[i-][j]==-)
continue;
for(k=;k<=n;k++){ //使用技能攻击
if(j-a[k]<) //如果剩余的MP不足以使用这个技能,则跳出本次循环
continue;
int temp;
temp=j-a[k]+t>?:j-a[k]+t;
if(dp[i][temp]==-){ //没到达过这个MP
dp[i][temp]=dp[i-][j]+b[k];
if(dp[i][temp]>=)
goto label;
}
else{ //说明之前有降到过这个MP,这个时候比较哪一个伤害高,记录伤害高的值
if(dp[i-][j]+b[k] > dp[i][temp]){ //如果当前技能伤害高
dp[i][temp]=dp[i-][j]+b[k];
if(dp[i][temp]>=)
goto label;
}
}
}
if(j+t>=){ //用普通攻击
if(dp[i-][j]+ > dp[i][]) {
dp[i][] = dp[i-][j]+;
if(dp[i][]>=)
goto label;
}
}
else{
if(dp[i-][j]+ > dp[i][j+t]){
dp[i][j+t]=dp[i-][j]+;
if(dp[i][j+t]>=)
goto label;
}
}
}
}
label:
if(i>T) //正常退出,代表在规定时间内没打死BOSS,你挂了
cout<<"My god"<<endl;
else
cout<<i<<endl;
}
return ;
}
Freecode : www.cnblogs.com/yym2013