码迷,mamicode.com
首页 > 移动开发 > 详细

Happy Three Friends

时间:2014-08-11 00:12:51      阅读:767      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   java   os   io   

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   水
 
bubuko.com,布布扣
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <cmath>
 5 #include <algorithm>
 6 #include <climits>
 7 #include <vector>
 8 #include <queue>
 9 #include <cstdlib>
10 #include <string>
11 #include <set>
12 #include <stack>
13 #define LL long long
14 #define INF 0x3f3f3f3f
15 using namespace std;
16 int d[8],n;
17 int main() {
18     int t,i,j,grapa,mzry;
19     scanf("%d",&t);
20     while(t--){
21         for(i = 0;i < 6; i++)
22             scanf("%d",d+i);
23         sort(d,d+6);
24         grapa = d[5]+d[4];
25         mzry = d[3]+d[2]+d[1];
26         if(grapa > mzry){
27             puts("Grandpa Shawn is the Winner!");
28         }else puts("What a sad story!");
29     }
30     return 0;
31 }
View Code

 

Happy Three Friends,布布扣,bubuko.com

Happy Three Friends

标签:des   style   blog   http   color   java   os   io   

原文地址:http://www.cnblogs.com/crackpotisback/p/3903610.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!