hdoj-4931-Happy Three Friends
2016-06-07 09:44
344 查看
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!
算是一个小贪心吧,题意很好懂,水题一个
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; }
相关文章推荐
- Android :短信验证码自动填写-v2
- Android学习开发之Android Studio-史上最全使用第三方库,本地jar 、 使用Module依赖、使用AAR、Maven、so等等
- IOS AVAudioRecorder 录制音频
- Swift-@UIApplicationMain
- 【android内核剖析笔记】APK程序的运行过程
- 遍历JObject
- Android 滑动开关按钮源码
- [Android 编译(一)] Ubuntu 16.04 LTS 成功编译 Android 6.0 源码教程
- android中对/data/data/<package name>/files下文件的读写操作
- APP图片缓存与Glide之signature的分析
- jetty项目部署与配置
- iOS 宏(define)与const的正确用法
- 实习入职第十七天:Android里面的颜色值#rgb, #argb, #rrggbb, or #aarrggbb
- 订餐系统之微信点餐
- iOS 生成二维码 官方版
- iOS中读取照片库及保存图片或视频到照片库的要点解析
- Universal-Image-Loader(android图片缓存)
- iOS UIWebView 修改user-agent
- System.Drawing.Design.UITypeEditor自定义控件属性GetEditStyle(ITypeDescriptorContext context),EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
- Android的View事件机制思维导图