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


1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 、4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合;、下载 4使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合;、 4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值