Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 5 Accepted Runs: 2
Muxiaokui now is wild about a card game named Hearthstone. In this game ,you should use cards to summon some monsters to fight with your opponent .
Unfortunately , muxiaokui's math was taught by a physical teacher . so he always missed the best time to defeat the opponent. And now he needs your help.
First ,muxiaokui and his opponent has a hero . The hero has his own HP, if you can put the opponent's HP to 0 or less, then you get the victory.
Now muxiaokui has N monsters. Muxiaokui's opponent has only one monster. Each monster has its HP and attack power. Muxiaokui's monster has a chance to attack a target
theopponentsheroorthetauntmonsters.
, make a damage X equal to its attack power, that means the targets HP should reduced X, and if the targets HP is not larger than 0,the target will died; However Muxiaokui's monster should kill the opponents monster in order to attack the opponents hero.
Without monsters, Muxiaokui also has M magic cards,every card can choose a target and make damage. It can make direct damage to heroes even if the opponents monster is still alive.
And now here is the question: whether there exists a way to make muxiaokui get the victory?
Input
The input contains an integer on the first line, which indicates the number of test cases
Each case consists of three lines, the first line contains four integers N,M,Aand B, represent the number of muxiaokuis monsters , the number of muxiaokuis magiccard ,the opponents heros HP, and the opponents monsters HP, separated by space.
(N<16,M<100,A,B<10000)
Then second line contains n integers, represent the attack power of all monsters, separated by space. All the attack power are less than 100.
Then third line contains m integers, represent the damaged of all magic card, separated by space. All the damaged are less than 100.
Ouput
If muxiaokui has a way to win the game ,output "wellplay", otherwise output "wash your face".
Sample Input
2 2 1 4 2 2 3 1 1 2 10 3 10 1 1
Sample Output
wellplay wash your face 题目分析:先判断是否卡牌能否干掉英雄,不行的话,做0/1背包,然后找到打败怪物所需的最小血量消耗,然后用总血量减去,判断是否大于英雄的血量#include <algorithm> #include <cstring> #include <cstdio> #include <iostream> #include <algorithm> #define MAX 50007 using namespace std; int t,n,m,a,b; int p[MAX]; int dp[MAX]; int main ( ) { scanf ( "%d" , &t ); while ( t-- ) { int sum = 0; int sum1 = 0; scanf ( "%d%d%d%d" , &n , &m , &a , &b ); for ( int i = 1 ; i <= n ; i++ ) { scanf ( "%d" , &p[i] ); sum1 += p[i]; } for ( int i = n+1 ; i <= n+m ; i++ ) { scanf ( "%d" , &p[i] ); sum += p[i]; } if ( sum >= a ) { puts ( "wellplay" ); continue; } memset ( dp , 0 , sizeof ( dp ) ); dp[0] = 1; for ( int i = 1 ; i <= n+m ; i++ ) for ( int j = 20000 ; j >= p[i] ; j-- ) if ( dp[j-p[i]] ) dp[j] = 1; int ans = 0; for ( int j = b ; j <= 20000 ; j++ ) if ( dp[j] ) { ans = j; break; } if ( sum1 + sum - ans >= a ) puts ( "wellplay" ); else puts ( "wash your face" ); } }