toj 4108 Hearthstone

4108.   Hearthstone
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" ); 
    }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值