标签:acm
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 70 Accepted Submission(s): 62
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!
解题思路:
六个数排序,比较最大的两个数的和 与 第二三四三个数的和 比较。
代码:
#include <iostream> #include <stdio.h> #include <string.h> #include <queue> #include <stack> #include <algorithm> #include <cmath> #include <iomanip> using namespace std; int num[8]; int main() { int t; cin>>t; while(t--) { for(int i=1;i<=6;i++) scanf("%d",&num[i]); sort(num+1,num+7); int dong=num[5]+num[6]; int other=num[4]+num[3]+num[2]; if(dong>other) cout<<"Grandpa Shawn is the Winner!"<<endl; else cout<<"What a sad story!"<<endl; } return 0; }
[BestCoder Round #4] hdu 4931 Happy Three Friends,布布扣,bubuko.com
[BestCoder Round #4] hdu 4931 Happy Three Friends
标签:acm
原文地址:http://blog.csdn.net/sr_19930829/article/details/38486511