hdoj4931Happy Three Friends
2016-02-16 17:44
232 查看
Happy Three Friends
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 784 Accepted Submission(s): 571
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!
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<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #include<cmath> #include<list> #include<queue> #include<vector> using namespace std; const int maxn=10; int num[maxn]; int main() { int t,i,j,k; scanf("%d",&t); while(t--){ for(i=0;i<6;++i){ scanf("%d",&num[i]); } sort(num,num+6); int g=num[5]+num[4],s=num[3]+num[1]+num[2]; if(g>s){ printf("Grandpa Shawn is the Winner!\n"); } else { printf("What a sad story!\n"); } } return 0; }
相关文章推荐
- THREE.JS入门教程(1)THREE.JS使用前了解
- Three.js源码阅读笔记(物体是如何组织的)
- Three.js源码阅读笔记(Object3D类)
- Three.js源码阅读笔记(光照部分)
- Three.js源码阅读笔记(基础的核心Core对象)
- HTML5画布阅读Three js Phong材料
- THREEJS阴影效果
- Three20 在xcode4.0上添加步骤 推荐
- 三杯茶(一本令全世界为之动容的书)(Three cups of tea) 推荐
- Three.JS 发光球体,材质纹理,缩放移动动画,教程
- Factor Attribution
- THREE.JS中常用的3种材质
- Leetcode - Power of Three
- 628. Maximum Product of Three Numbers
- LeetCode之旅(20)-Power of Three
- leetcode之Power of Three
- HTML5 Three.js 3D特效
- three.js实例
- Codeforces 591E - Three States 【BFS】
- ajax bufferarray three中loader的实现原理