【CUGBACM15级BC第四场 A】hdu 4931 Happy Three Friends
来源:互联网 发布:图片剪裁软件 编辑:程序博客网 时间:2024/06/06 05:32
Happy Three Friends
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1030 Accepted Submission(s): 764
Total Submission(s): 1030 Accepted Submission(s): 764
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.
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 ).
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!"
If he can not , output "What a sad story!"
Sample Input
31 2 3 3 2 22 2 2 2 2 21 2 2 2 3 4
Sample Output
What a sad story!What a sad story!Grandpa Shawn is the Winner!HintFor 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 <iostream>#include <set>#include <map>#include <stack>#include <cmath>#include <queue>#include <cstdio>#include <bitset>#include <string>#include <vector>#include <iomanip>#include <cstring>#include <algorithm>#include <functional>#define PI acos(-1)#define eps 1e-8#define inf 0x3f3f3f3f#define debug(x) cout<<"---"<<x<<"---"<<endltypedef long long ll;using namespace std;int a[105];int main(){ int t; scanf("%d", &t); while (t--) { memset(a, 0, sizeof(a)); for (int i = 0; i < 6; i++) { scanf("%d", &a[i]); } sort(a, a + 6, greater<int>()); int sum1 = a[0] + a[1]; int sum2 = a[2] + a[3] + a[4]; if (sum1 > sum2) { printf("Grandpa Shawn is the Winner!\n"); } else { printf("What a sad story!\n"); } } return 0;}
阅读全文
0 0
- 【CUGBACM15级BC第四场 A】hdu 4931 Happy Three Friends
- hdu 4931 /BC 4A Happy Three Friends
- 【CUGBACM15级BC第15场 A】hdu 5083 Love
- 【CUGBACM15级BC第17场 A】hdu 5100 Chessboard
- 【CUGBACM15级BC第23场 A】hdu 5146 Sequence
- 【CUGBACM15级BC第8场 A】hdu 4989 Summary
- 【CUGBACM15级BC第五场 A】hdu 4956 Poor Hanamichi
- 【CUGBACM15级BC第31场 A】hdu 5178 pairs
- 【CUGBACM15级BC第三场 A】hdu 4907 Task schedule
- 【CUGBACM15级BC第1场 A】hdu 4857 逃生
- hdu 4931 Happy Three Friends
- HDU 4931 Happy Three Friends
- 【CUGBACM15级BC第四场 B】hdu 4932 Miaomiao's Geometry
- hdu 4931 Happy Three Friends(水题)
- HDU 4931 Happy Three Friends(水)
- 【CUGBACM15级BC第12场 A】【STL】hdu 5058 So easy
- 【CUGBACM15级BC第11场 A】hdu 5054 Alice and Bob
- 【CUGBACM15级BC第13场 A】hdu 5062 Beautiful Palindrome Number
- Java-静态static用法
- 记录我的小网站之旅
- Esp8266学习之旅① 搭建开发环境,开始一个“hellow world”串口打印。
- 第一次上课:特征值特征向量的几何直观
- 简单程序
- 【CUGBACM15级BC第四场 A】hdu 4931 Happy Three Friends
- eclipse中透过search打开第二个文件时第一个文件就自己关闭了
- Android -结束当前activity并返回上一个activity
- Pthreads 多线程入门教程
- 列,表,行,行中元素mysql常用语句
- hdu 1285
- Windows下eclipse连接远程Hadoop+Hbase+zookeeper
- 67 个拯救前端开发者的工具、库和资源
- Opencv入门-第一回-梦牵机器视觉翼,初识Opencv域(安装Opencv)