[BestCoder Round #4] hdu 4931 Happy Three Friends

Happy Three Friends

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 70    Accepted Submission(s): 62


Problem Description

 

Dong-hao , Grandpa Shawn , Beautful-leg Mzry are good friends. One day , they want to play a game.

There are 6 numbers on the table.  

Firstly , Dong-hao can change the order of 6 numbers.

Secondly , Grandpa Shawn take the first one and the last one , sum them up as his scores.

Thirdly , Beautiful-leg Mzry take any of 3 numbers from the last 4 numbers , and sum them up as his scores.

Finally , if Grandpa Shawn's score is larger than Beautiful-leg Mzry's , Granpa Shawn wins!  

If Grandpa Shawn's score is smaller than Beautiful-leg Mzry's , Granpa Shawn loses.

If the scores are equal , there is a tie.

Nowadays , it's really sad that Grandpa Shawn loses his love. So Dong-hao wants him to win(not even tie). You have to tell Dong-hao whether he can achieve his goal.
 


 

Input

 

There is a number T shows there are T test cases below. ( T <= 50)

For each test case , there are 6 numbers Ai ( 1 <= Ai <= 100 ).
 


 

Output

 

If Dong-hao can achieve his goal , output "Grandpa Shawn is the Winner!"
If he can not , output "What a sad story!"
 


 

Sample Input

 

  
  
3 1 2 3 3 2 2 2 2 2 2 2 2 1 2 2 2 3 4
 


 

Sample Output

 

  
  
What a sad story! What a sad story! Grandpa Shawn is the Winner!
Hint
For the first test case , {3 , 1 , 2 , 2 , 2 , 3} Grandpa Shawn can take 6 at most . But Beautiful-leg Mzry can take 6 too. So there is a tie. For the second test cases , Grandpa Shawn loses. For the last one , Dong-hao can arrange the numbers as {3 , 2 , 2 , 2 , 1 , 4} , Grandpa Shawn can take 7 , but Beautiful-leg Mzry can take 6 at most. So Grandpa Shawn Wins!
 


 

Source

 

 

解题思路:

六个数排序,比较最大的两个数的和  与 第二三四三个数的和  比较。

代码:

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int num[8];

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        for(int i=1;i<=6;i++)
            scanf("%d",&num[i]);
        sort(num+1,num+7);
        int dong=num[5]+num[6];
        int other=num[4]+num[3]+num[2];
        if(dong>other)
            cout<<"Grandpa Shawn is the Winner!"<<endl;
        else
            cout<<"What a sad story!"<<endl;
    }
    return 0;
}


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值