HDU 3008 Warcraft

9056 ワード

Warcraft
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 751    Accepted Submission(s): 383
Problem Description
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!
 
 
Input
There are several test cases,intergers n ,t and q (00) in the first line which mean you own n kinds of skills ,and the "ResumingCirclet"helps you resume t points of MagicValue per second and q is of course the hurt points of LifeValue the Boss attack you each time(we assume when fighting in a second the attack you show is before the Boss).Then n lines follow,each has 2 intergers ai and bi(0 
 
Output
Output an interger min (the minimun time you need to kill the Boss)in one line .But if you die(the LifeValue is no more than 0) ,output "My god"!
 
 
Sample Input
4 2 25
10 5
20 10
30 28
76 70
4 2 25
10 5
20 10
30 28
77 70
0 0 0
 
 
Sample Output
4
My god
 
 
Hint
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!
 
 
Source
2009 Multi-University Training Contest 11 - Host by HRBEU
 
 
Recommend
gaojie
 
 
 
 
構想:テーマの変数は少し多いが、いくつかは変わらないので、状態を定義するときはこれらを無視することができて、それから明らかに状態を定義することができて、状態を定義した後に実は01リュックサックであることを発見して、それから01リュックサックの構想に従って書くのが正しいです;
状態dp[magic_value][attack_times]を定義し、左下標対応攻撃がk回目を終了した後、右下標対応の値は残りの魔法値、配列の値はboss残りの血量とする.
じょうたいてんいほうていしき
dp[magic_value][k] = max(dp[magic_value][k] , dp[j][k - 1] + skill[i].dps);
 
 
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

const int maxn=120;
const int magic_val=120;
const int attack_times=120;

int dp[magic_val][attack_times];

struct node{
    int cost,dps;
}skill[maxn];

int max(int a,int b){
    return a>b?a:b;
}

int main(){

    //freopen("input.txt","r",stdin);

    int n,t,q;
    while(scanf("%d%d%d",&n,&t,&q)){
        if(n==0 && t==0 && q==0)
            break;
        memset(dp,0,sizeof(dp));
        int i,j,k,res=0;
        for(i=0;i<n;i++)
            scanf("%d%d",&skill[i].cost,&skill[i].dps);
        skill[n].cost=0;skill[n].dps=1;
        for(k=1;k<=100;k++){        //    100   
            if(res)
                break;
            for(i=0;i<=n;i++)
                for(j=100;j>=skill[i].cost;j--){
                    int mag=j-skill[i].cost+t;
                    if(mag>100)
                        mag=100;
                    dp[mag][k]=max(dp[mag][k],dp[j][k-1]+skill[i].dps);
                    if(dp[mag][k]>=100)
                        res=k;
                }
        }
        if((res-1)*q>=100)
            printf("My god
"); else printf("%d
",res); } return 0; }