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 DescriptionDong-hao, Grandpa Shawn, Beautful-leg Mzry is good friends. One day, they want to play a game.
There is 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 all 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 is equal, there is a tie.
Nowadays, it ' s really sad that Grandpa Shawn loses he love. So Dong-hao wants him-to-win (not even tie). You have a to-tell Dong-hao whether he can achieve he goal.
InputThere is a number T shows there is t test cases below. (T <= 50)
For each test case, there is 6 numbers AI (1 <= ai <= 100).
OutputIf Dong-hao can achieve his goal, output "Grandpa Shawn is the winner!"
If he can not and output "what a sad story!"
Sample Input31 2 3 3 2 22 2 2 2 2 21 2 2 2 3 4
Sample OutputWhat 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 the 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 the most. So Grandpa Shawn wins! Problem solving: ( ̄o ̄). Z Z Water
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>Ten#include <string> One#include <Set> A#include <stack> - #defineLL Long Long - #defineINF 0x3f3f3f3f the using namespacestd; - intd[8],n; - intMain () { - intT,i,j,grapa,mzry; +scanf"%d",&t); - while(t--){ + for(i =0; I <6; i++) Ascanf"%d", d+i); atSort (d,d+6); -Grapa = d[5]+d[4]; -Mzry = d[3]+d[2]+d[1]; - if(Grapa >Mzry) { -Puts"Grandpa Shawn is the winner!"); -}ElsePuts"What a sad story!"); in } - return 0; to}
View Code