Happy Three Friends

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

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!

 
解题:( ̄o ̄) . z Z   水
 
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <cstdlib>
#include <string>
#include <set>
#include <stack>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
int d[],n;
int main() {
int t,i,j,grapa,mzry;
scanf("%d",&t);
while(t--){
for(i = ;i < ; i++)
scanf("%d",d+i);
sort(d,d+);
grapa = d[]+d[];
mzry = d[]+d[]+d[];
if(grapa > mzry){
puts("Grandpa Shawn is the Winner!");
}else puts("What a sad story!");
}
return ;
}

随机推荐

  1. hdu 1025 Constructing Roads In JGShining's Kingdom

    本题明白题意以后,就可以看出是让求最长上升子序列,但是不知道最长上升子序列的算法,用了很多YY的方法去做,最后还是超时, 因为普通算法时间复杂度为O(n*2),去搜了题解,学习了一下,感觉不错,拿出来 ...

  2. 洛谷 P2634 [国家集训队]聪聪可可

    点分板子2333 注释都是错过的地方 #include<cstdio> #include<algorithm> using namespace std; typedef lon ...

  3. GIT配置及用法

    ssh配置 TortoiseGit配置 用法: 下面是我整理的常用 Git 命令清单.几个专用名词的译名如下. Workspace:工作区 Index / Stage:暂存区 Repository:仓 ...

  4. call方法的使用bug--参数undefined

    call/apply是函数原型定义的方法(Function.prorotype),在使用时要注意第一个形参(args[0]),一定是指向函数所要挂载的上下文对象--context,若对象非必须,则要将 ...

  5. git 恢复误删的文件

    误删的文件如何恢复呢? 执行下面的命令: 1. git reset HEAD a.txt 2. git checkout a.txt 注意:上面两个命令,可以帮我们找回删除的文件,但是对文件内容的修改 ...

  6. Android SDK镜像更新网速慢的解决问题

    通过更换代理解决 Android SDK 在线更新镜像服务器资源:大连东软信息学院镜像服务器地址:http://mirrors.neusoft.edu.cn 端口:80北京化工大学镜像服务器地址:IP ...

  7. ASP.NET Excel下载方法一览

    方法一 通过GridView(简评:方法比较简单,但是只适合生成格式简单的Excel,且无法保留VBA代码),页面无刷新 aspx.cs部分 using System; using System.Co ...

  8. 中国版 Office 365 (X-Tenant / Tango) 功能验证报告 - 1 简介

    花了点时间做了一次Office 365 X-Tenant的 POC,对过程做了记录和总结,在这里会陆续分享: (一) 简介 这次POC的系统环境是模拟一个公司的生产环境: 1. 公司总部在国外,拥有 ...

  9. Android嵌入式安卓触摸屏|4418开发板平台

    核心板参数 尺寸:50mm*60mm 高度:核心板连接器为1.5mm 4418 CPU:ARM Cortex-A9 四核 S5P4418处理器 1.4GHz 6818 CPU:ARM Cortex-A ...

  10. SQL条件语句(IF, CASE WHEN, IF NULL)

    1.IF   表达式:IF( expr1 , expr2 , expr3 )   expr1条件,条件为true,则值是expr2 ,false,值就是expr3 SELECT o.id,u.acco ...