标签:des style color java os io strong for
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 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 ).
If Dong-hao can achieve his goal , output "Grandpa Shawn is the Winner!" If he can not , output "What a sad story!"
3 1 2 3 3 2 2 2 2 2 2 2 2 1 2 2 2 3 4
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!
直接把最大2个放外面,Beautiful-leg Mzry剩下的中再取最大的3个
#include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<functional> #include<iostream> #include<cmath> #include<cctype> #include<ctime> using namespace std; #define For(i,n) for(int i=1;i<=n;i++) #define Fork(i,k,n) for(int i=k;i<=n;i++) #define Rep(i,n) for(int i=0;i<n;i++) #define ForD(i,n) for(int i=n;i;i--) #define RepD(i,n) for(int i=n;i>=0;i--) #define Forp(x) for(int p=pre[x];p;p=next[p]) #define Lson (x<<1) #define Rson ((x<<1)+1) #define MEM(a) memset(a,0,sizeof(a)); #define MEMI(a) memset(a,127,sizeof(a)); #define MEMi(a) memset(a,128,sizeof(a)); #define INF (2139062143) #define F (100000007) #define MAXN () #define MAXM () long long mul(long long a,long long b){return (a*b)%F;} long long add(long long a,long long b){return (a+b)%F;} long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;} typedef long long ll; int a[7],t; int main() { // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); cin>>t; while (t--) { For(i,6) cin>>a[i]; sort(a+1,a+7); if (a[6]+a[5]>a[4]+a[3]+a[2]) cout<<"Grandpa Shawn is the Winner!"<<endl; else cout<<"What a sad story!"<<endl; } return 0; }
BestCoder Round #4(Happy Three Friends-贪心),布布扣,bubuko.com
BestCoder Round #4(Happy Three Friends-贪心)
标签:des style color java os io strong for
原文地址:http://blog.csdn.net/nike0good/article/details/38586005