hdoj-4931-Happy Three Friends
来源:互联网 发布:网络违法举报网站 编辑:程序博客网 时间:2024/05/17 05:05
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!
算是一个小贪心吧,题意很好懂,水题一个
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int main(){ int t; scanf("%d",&t); int a[10]; while(t--) { int sum=0; for(int i=0;i<6;i++) { scanf("%d",&a[i]); sum+=a[i]; } sort(a,a+6); int cnt=a[4]+a[5]; sum-=(cnt+a[0]); if(cnt>sum) printf("Grandpa Shawn is the Winner!\n"); else printf("What a sad story!\n"); } return 0;}
- HDOJ 4931 Happy Three Friends
- hdoj-4931-Happy Three Friends
- [4931]:Happy Three Friends
- hdu 4931 Happy Three Friends
- HDU 4931 Happy Three Friends
- hdu 4931 Happy Three Friends(水题)
- HDU 4931 Happy Three Friends(水)
- HDOJ4931 - Happy Three Friends
- [BestCoder Round #4] hdu 4931 Happy Three Friends
- hdu 4931 /BC 4A Happy Three Friends
- BestCoder Round #4(Happy Three Friends-贪心)
- HDU 4931 Happy Three Friends(水题)——BestCoder Round #4
- 【CUGBACM15级BC第四场 A】hdu 4931 Happy Three Friends
- HDOJ 5119 Happy Matt Friends DP
- Bestcoder4——Happy Three Friends(二叉堆)
- hdu4931 Happy Three Friends(BestCoder Round#4签到题)
- hdoj Happy Matt Friends 5119 (DP) 好题
- My Friends, Happy Xmas
- 调用WebService时加入身份验证,以拒绝未授权的访问
- 静态数据成员的Point 类
- 子线程之后到主线程
- Android :短信验证码自动填写-v2
- 增加、删除HTML元素
- hdoj-4931-Happy Three Friends
- Apache Commons BeanUtils包学习(2)-beanutils.PropertyUtils, beanutils.DynaBean
- 关于javaScript获取窗体大小
- Hibernate使用sql语句查询
- AQS(AbstractQueuedSynchronizer)源码分析
- Reveal + 越狱真机查看第三方app的UI结构
- UML类图画法及其之间的几种关系
- typedef函数指针用法
- NSIS安装包制作