Zoj 2297 Survival pressure DP

Source: Internet
Author: User

Description
The King of Fighter (KOF97) is an electronic game of wrestling type. Once It was fashionable among youths. The game is amused. However, playing by oneself are not as excited as with friends. Getting bored? Maybe can alter to the survival mode.

In the survival mode, you play as usual, but under quite unfair conditions:you must use your only character to beat all T He other characters and Orichi as well (who is the BOSS)!!! How can I do that? We know that usually we'll consume some HP of the character to beat one opponent. Although the character would recover some hp after beating one opponent, the amount of HP recovered are affected by the time Used, so it?? s possible that the character lose some HP after one round. What?? S worse, if the HP of your character is not enough for your beat your opponent, you lose!

Given the HP your character you need to consume and the HP your character would recover if you win for every opponent, Y OU is to determine whether you can clear the game.

Note:
1. The initial HP of your character is 100.
2. You can challenge your opponents on any order except that Orichi are always the last one.
3. If your HP Falls BELOW Zero after any fights (before recovery), you'll get the your mission failed. 4. Your HP should never exceed 100.

Input

There is multiple test cases, which is separated by a blank line. The first line of all test case was a single integer n (1 <= n <=), gives the number of opponents you need to Bea T. The following N? C 1 lines each contain a integers c and r (0 <= C, r <=), where C for the HP you need to consume to beat the O Pponent and R for the HP recovered after you beat the opponent. The last line contains only one integer p (0 <= P <=), describing the HP you need to consume to beat Orichi.

Output

For each test case, generate one line of output:if you can clear the game, print "clear!!!" otherwise print "Try Again" ( both without quotations).

Sample Input

3
50 50
40 40
70

Sample Output

Clear!!!

Hit a strange, kill a little monster to drop A's blood, fight after death can restore B's blood. Finally hit boss, to drop the blood of M.,,, blood can not more than 100, less than 0 died ... Ask if you can live to kill boss ... (Kill all the Little monsters first, play boss)

#include <cstdio>#include <cmath>#include <cstring>#include <iostream>#include <algorithm>#include <queue>#include <vector>#include <map>#include <stack>#pragma COMMENT (linker, "/stack:102400000,102400000")#define PI ACOs ( -1.0)#define EPS 1e-6#define INF (1<<24)using namespace STD;intdp[1<< +];structugly{intLose;intget;} ugly[ A];intBossintMain () {intN while(scanf("%d", &n)!=eof) {intI,j; for(i=1; i<n;i++)scanf("%d%d", &ugly[i].lose,&ugly[i].get);scanf("%d", &boss);intZhuang= (1<< (n1))-1;//2^n-1        memset(DP,0,sizeof(DP)); dp[0]= -; for(i=0; i<=zhuang;i++) for(j=1; j<n;j++) {intk=1<< (J-1);if(! (i&k) &&dp[i]>=ugly[j].lose)//No State of the first J, and the blood at this time is enough to kill the J-Monsters .{Dp[i+k]=max (dp[i+k],dp[i]-ugly[j].lose+ugly[j].get);if(dp[i+k]> -) dp[i+k]= -; }        }if(Dp[zhuang]>=boss)printf(the Clear!!! \ n ");Else printf("Try again\n"); }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Zoj 2297 Survival pressure DP

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.