HDU 3008 Warcraft (DP)

Source: Internet
Author: User
Tags min

Warcraft Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 1910 Accepted Submission (s): 1028


Problem Description has you ever played the Warcraft? It doesn ' t matter whether you have played it! We'll give you such an experience. There is so many heroes in it,but you could only choose one of them. Each Hero have his own skills. When such a Skill was 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 your to complete such a duty to kill the Boss (so cool~~). To simplify the problem:you can assume the lifevalue of the monster are, your lifevalue is 100,but we have also a 100 magicvalue! You can choose to use the ordinary Attack (which doesn ' t cost magicvalue), or a certain skill (in condition so you own this Skill and the magicvalue you had at that time are no less than the skill costs), there are no free lunch so this you should Pay certain magicvalue after your use one skill! But we were good enough to offer you a "Resumingcirclet" (with which can resume the magicvalue each seconds), but can ' t own more than magicvalue and resuming magicvalue are always after you attack. The Boss is cruel, being careful!
Input There is several test cases,intergers N, T and Q (0&LT;N&LT;=100,1&LT;=T&LT;=5,Q&GT;0) in the first line which mean You own n kinds of skills, and the "Resumingcirclet" helps your resume T points of magicvalue per second and q is of cours E The hurt points of Lifevalue the Boss attack all time (we assume when fighting in a second the attack you show is being Fore the Boss). Then n lines follow,each have 2 intergers ai and Bi (0<ai,bi<=100). Which means using I skill costs you ai magicvalue a nd costs The Boss bi lifevalue.the is n=t=q=0.
Output Output an Interger min (the minimun time need to kill the Boss) in one line. But if your die (the Lifevalue are no more than 0), output "My God"!
Sample Input

4 2 2510 520 1030 2876 704 2 2510 520 1030 2877 700 0 0
Sample Output
4My God Hint hint:when fighting,you can only choose one kind of skill or just to use the ordinary attack in the whole Seco Nd,the ordinary attack costs The boss 1 points of Lifevalue,the boss can only use ordinary attack which costs a whole seco nd at a time. Good Luck to you!

Test instructions: The Monster's blood quantity has 100, the attack is Q, your initial blood volume and the blue are 100, the ordinary attack power is 1 (does not consume the blue), uses the skill to cause the damage to need the blue, every 2s you will increase the T point Blue value upper limit is 100 (you latter monster attack calculates one second), asks at least several rounds God.

DP[I][J], which represents the maximum attack caused by the J-point blue value of the first attack.

Dp[i][min (j+t, +)] = max{dp[i-1][j+num[k]]+skill[k]};

#include <bits/stdc++.h> #include <ext/hash_map> #include <ext/hash_set> #include <ext/pb_ds/
assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/priority_queue.hpp>
using namespace Std;
using namespace __gnu_cxx;
using namespace __gnu_pbds; #define Xinf Int_max #define INF 0x3f3f3f3f #define MP (x, y) make_pair #define PB (x) push_back (×) #define REP (X,n) for (int x=0; x<n; x + +) #define REP2 (X,L,R) for (int x=l; x<=r; x + +) #define DEP (x,r,l) for (int x=r; x>=l;
x--) #define CLR (a,x) memset (a,x,sizeof (A)) #define IT iterator #define RIT reverse_iterator typedef long Long LL;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<pii> VII;
typedef vector<int> VI;
typedef TREE&LT;PII, Null_type, Greater<pii>, Rb_tree_tag, Tree_order_statistics_node_update > Rb_tree_set;
typedef TREE&LT;PII, PII, Greater<pii>, Rb_tree_tag, Tree_order_statistics_node_update > Rb_tree; #defiNE PQ std::p riority_queue #define HEAP __gnu_pbds::p riority_queue #define X First #define Y second #define LSON (x) ((x) &lt
; <1) #define Rson (x) ((x) <<1|1) #define N #define M 200010 int skill[n], num[n];
int dp[n][n];
    int main () {int n, q, t;
        while (scanf ("%d%d%d", &n, &t, &q)! = EOF, n|q|t) {int times = 100/q + (100%q==0?0:1);
        memset (DP, 0, sizeof (DP));
        for (int i = 1; I <= n; i++) {scanf ("%d%d", &num[i], &skill[i]);
        } Num[0] = 0;
        Skill[0] = 1;
        DP[0][100] = 0;
        int pos=0;  for (int i = 1; I <= times, i++) {for (int j = 0; J <=, J + +) {int temp= (j+t) >100? 
                100:j+t; for (int k = 0; k <= N; k++) {if (J+num[k] <=) {dp[i][temp] = max (DP I
                    [temp], dp[i-1][j+num[k]]+skill[k]);
}} if (Dp[i][temp] >= 100) {                    pos = i;
                Break
        }} if (POS) break;
        } if (POS) printf ("%d\n", POS);
    else printf ("My god\n");
} return 0;
 }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.